diff options
125 files changed, 933 insertions, 667 deletions
diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php index f4915c3d2fe..4e0803f791b 100755 --- a/apps/admin_dependencies_chk/settings.php +++ b/apps/admin_dependencies_chk/settings.php @@ -21,7 +21,7 @@ * */ $l=OC_L10N::get('admin_dependencies_chk'); -$tmpl = new OC_Template( 'admin_dependencies_chk', 'settings'); +$tmpl = new OCP\Template( 'admin_dependencies_chk', 'settings'); $modules = array(); @@ -69,11 +69,23 @@ $modules[] =array( 'message'=> $l->t('The php-ctype module is needed validate data.')); $modules[] =array( + 'status' => class_exists('DOMDocument') ? 'ok' : 'error', + 'part'=> 'php-xml', + 'modules'=> array('core'), + 'message'=> $l->t('The php-xml module is needed to share files with webdav.')); + +$modules[] =array( 'status' => ini_get('allow_url_fopen') == '1' ? 'ok' : 'error', 'part'=> 'allow_url_fopen', 'modules'=> array('core'), 'message'=> $l->t('The allow_url_fopen directive of your php.ini should be set to 1 to retrieve knowledge base from OCS servers')); +$modules[] =array( + 'status' => class_exists('PDO') ? 'ok' : 'warning', + 'part'=> 'php-pdo', + 'modules'=> array('core'), + 'message'=> $l->t('The php-pdo module is needed to store owncloud data into a database.')); + foreach($modules as $key => $module) { $enabled = false ; foreach($module['modules'] as $app) { diff --git a/apps/admin_migrate/settings.php b/apps/admin_migrate/settings.php index 7d3fd041798..daa56390aff 100755 --- a/apps/admin_migrate/settings.php +++ b/apps/admin_migrate/settings.php @@ -52,6 +52,6 @@ if (isset($_POST['admin_export'])) { } else { // fill template - $tmpl = new OC_Template('admin_migrate', 'settings'); + $tmpl = new OCP\Template('admin_migrate', 'settings'); return $tmpl->fetchPage(); }
\ No newline at end of file diff --git a/apps/bookmarks/appinfo/info.xml b/apps/bookmarks/appinfo/info.xml index 39779483d85..4dbb74bb767 100644 --- a/apps/bookmarks/appinfo/info.xml +++ b/apps/bookmarks/appinfo/info.xml @@ -5,5 +5,6 @@ <description>Bookmark manager for ownCloud</description> <licence>AGPL</licence> <author>Arthur Schiwon, Marvin Thomas Rabe</author> + <standalone/> <require>2</require> -</info>
\ No newline at end of file +</info> diff --git a/apps/bookmarks/index.php b/apps/bookmarks/index.php index f545d79da61..a4ce0229876 100755 --- a/apps/bookmarks/index.php +++ b/apps/bookmarks/index.php @@ -32,6 +32,6 @@ OCP\App::setActiveNavigationEntry( 'bookmarks_index' ); OCP\Util::addscript('bookmarks','bookmarks'); OCP\Util::addStyle('bookmarks', 'bookmarks'); -$tmpl = new OC_Template( 'bookmarks', 'list', 'user' ); +$tmpl = new OCP\Template( 'bookmarks', 'list', 'user' ); $tmpl->printPage(); diff --git a/apps/bookmarks/settings.php b/apps/bookmarks/settings.php index 9d945f64dad..6db36176330 100644..100755 --- a/apps/bookmarks/settings.php +++ b/apps/bookmarks/settings.php @@ -6,6 +6,6 @@ * See the COPYING-README file. */ -$tmpl = new OC_Template( 'bookmarks', 'settings'); +$tmpl = new OCP\Template( 'bookmarks', 'settings'); return $tmpl->fetchPage(); diff --git a/apps/calendar/ajax/calendar/edit.form.php b/apps/calendar/ajax/calendar/edit.form.php index 17118c5165f..77366809311 100755 --- a/apps/calendar/ajax/calendar/edit.form.php +++ b/apps/calendar/ajax/calendar/edit.form.php @@ -12,7 +12,7 @@ OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); -$tmpl = new OC_Template("calendar", "part.editcalendar"); +$tmpl = new OCP\Template("calendar", "part.editcalendar"); $tmpl->assign('new', false); $tmpl->assign('calendarcolor_options', $calendarcolor_options); $tmpl->assign('calendar', $calendar); diff --git a/apps/calendar/ajax/calendar/edit.php b/apps/calendar/ajax/calendar/edit.php index 17118c5165f..77366809311 100755 --- a/apps/calendar/ajax/calendar/edit.php +++ b/apps/calendar/ajax/calendar/edit.php @@ -12,7 +12,7 @@ OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); -$tmpl = new OC_Template("calendar", "part.editcalendar"); +$tmpl = new OCP\Template("calendar", "part.editcalendar"); $tmpl->assign('new', false); $tmpl->assign('calendarcolor_options', $calendarcolor_options); $tmpl->assign('calendar', $calendar); diff --git a/apps/calendar/ajax/calendar/new.form.php b/apps/calendar/ajax/calendar/new.form.php index fa30b871e42..ee46757f56b 100755 --- a/apps/calendar/ajax/calendar/new.form.php +++ b/apps/calendar/ajax/calendar/new.form.php @@ -15,7 +15,7 @@ $calendar = array( 'displayname' => '', 'calendarcolor' => '', ); -$tmpl = new OC_Template('calendar', 'part.editcalendar'); +$tmpl = new OCP\Template('calendar', 'part.editcalendar'); $tmpl->assign('new', true); $tmpl->assign('calendarcolor_options', $calendarcolor_options); $tmpl->assign('calendar', $calendar); diff --git a/apps/calendar/ajax/calendar/new.php b/apps/calendar/ajax/calendar/new.php index 4b8688e3d1d..76dbef6b9df 100755 --- a/apps/calendar/ajax/calendar/new.php +++ b/apps/calendar/ajax/calendar/new.php @@ -29,7 +29,7 @@ $calendarid = OC_Calendar_Calendar::addCalendar($userid, strip_tags($_POST['name OC_Calendar_Calendar::setCalendarActive($calendarid, 1); $calendar = OC_Calendar_Calendar::find($calendarid); -$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); +$tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), diff --git a/apps/calendar/ajax/calendar/overview.php b/apps/calendar/ajax/calendar/overview.php index 586bf3db814..96312537507 100755 --- a/apps/calendar/ajax/calendar/overview.php +++ b/apps/calendar/ajax/calendar/overview.php @@ -10,6 +10,6 @@ $l10n = OC_L10N::get('calendar'); OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('calendar'); -$output = new OC_TEMPLATE("calendar", "part.choosecalendar"); +$output = new OCP\Template("calendar", "part.choosecalendar"); $output -> printpage(); ?> diff --git a/apps/calendar/ajax/calendar/update.php b/apps/calendar/ajax/calendar/update.php index 408ac900912..3b1cc32b316 100755 --- a/apps/calendar/ajax/calendar/update.php +++ b/apps/calendar/ajax/calendar/update.php @@ -30,7 +30,7 @@ OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $calendar = OC_Calendar_App::getCalendar($calendarid); -$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); +$tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index 91d07d3897a..f2ea84dd205 100755 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -206,9 +206,9 @@ $repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); if($access == 'owner' || $access == 'rw'){ - $tmpl = new OC_Template('calendar', 'part.editevent'); + $tmpl = new OCP\Template('calendar', 'part.editevent'); }elseif($access == 'r'){ - $tmpl = new OC_Template('calendar', 'part.showevent'); + $tmpl = new OCP\Template('calendar', 'part.showevent'); } $tmpl->assign('eventid', $id); diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php index 42cdb81642e..f47cb6c3e2a 100755 --- a/apps/calendar/ajax/event/new.form.php +++ b/apps/calendar/ajax/event/new.form.php @@ -43,7 +43,7 @@ $repeat_bymonth_options = OC_Calendar_App::getByMonthOptions(); $repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); -$tmpl = new OC_Template('calendar', 'part.newevent'); +$tmpl = new OCP\Template('calendar', 'part.newevent'); $tmpl->assign('access', 'owner'); $tmpl->assign('calendar_options', $calendar_options); $tmpl->assign('repeat_options', $repeat_options); diff --git a/apps/calendar/ajax/import/dialog.php b/apps/calendar/ajax/import/dialog.php index e686066a993..3be02d2a6db 100755 --- a/apps/calendar/ajax/import/dialog.php +++ b/apps/calendar/ajax/import/dialog.php @@ -9,7 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); -$tmpl = new OC_Template('calendar', 'part.import'); +$tmpl = new OCP\Template('calendar', 'part.import'); $tmpl->assign('path', $_POST['path']); $tmpl->assign('filename', $_POST['filename']); $tmpl->printpage(); diff --git a/apps/calendar/ajax/share/dropdown.php b/apps/calendar/ajax/share/dropdown.php index bac487f0d0b..a3b0faca4bf 100755 --- a/apps/calendar/ajax/share/dropdown.php +++ b/apps/calendar/ajax/share/dropdown.php @@ -13,6 +13,6 @@ if($calendar['userid'] != $user){ OCP\JSON::error(); exit; } -$tmpl = new OC_Template('calendar', 'share.dropdown'); +$tmpl = new OCP\Template('calendar', 'share.dropdown'); $tmpl->assign('calid', $calid); $tmpl->printPage();
\ No newline at end of file diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 5aee5f6ace8..cf03a7a3cd3 100755 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -53,7 +53,7 @@ OCP\Util::addStyle('', 'jquery.multiselect'); OCP\Util::addscript('contacts','jquery.multi-autocomplete'); OCP\Util::addscript('','oc-vcategories'); OCP\App::setActiveNavigationEntry('calendar_index'); -$tmpl = new OC_Template('calendar', 'calendar', 'user'); +$tmpl = new OCP\Template('calendar', 'calendar', 'user'); $tmpl->assign('eventSources', $eventSources); $tmpl->assign('categories', $categories); if(array_key_exists('showevent', $_GET)){ diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 3d4174a57be..f0a9bf050fc 100755 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -105,10 +105,11 @@ class OC_Calendar_Object{ $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); + $object_id = OCP\DB::insertid('*PREFIX*calendar_objects'); OC_Calendar_Calendar::touchCalendar($id); - return OCP\DB::insertid('*PREFIX*calendar_objects'); + return $object_id; } /** @@ -124,10 +125,11 @@ class OC_Calendar_Object{ $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); + $object_id = OCP\DB::insertid('*PREFIX*calendar_objects'); OC_Calendar_Calendar::touchCalendar($id); - return OCP\DB::insertid('*PREFIX*calendar_objects'); + return $object_id; } /** diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index a53bf763324..488495aefc4 100755 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -25,7 +25,7 @@ class OC_Calendar_Share{ }else{ $active_where = ''; } - $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where); + $stmt = OCP\DB::prepare("SELECT * FROM *PREFIX*calendar_share_" . $type . " WHERE ((share = ? AND sharetype = 'user') " . $group_where . ") AND owner <> ? " . $permission_where . " " . $active_where); $result = $stmt->execute(array($userid, $userid)); $return = array(); while( $row = $result->fetchRow()){ @@ -160,7 +160,7 @@ class OC_Calendar_Share{ $i = 0; foreach($groups as $group){ $group_where .= ' OR '; - $group_where .= ' (share = "' . $group . '" AND sharetype = "group") '; + $group_where .= " (share = '" . $group . "' AND sharetype = 'group') "; $i++; } return $group_where; @@ -169,7 +169,7 @@ class OC_Calendar_Share{ $permission_where = ''; if(!is_null($permission)){ $permission_where = ' AND permissions = '; - $permission_where .= ($permission=='rw')?'"1"':'"0"'; + $permission_where .= ($permission=='rw')?"'1'":"'0'"; } return $permission_where; } @@ -191,7 +191,7 @@ class OC_Calendar_Share{ public static function is_editing_allowed($share, $id, $type){ $group_where = self::group_sql(OC_Group::getUserGroups($share)); $permission_where = self::permission_sql('rw'); - $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where); + $stmt = OCP\DB::prepare("SELECT * FROM *PREFIX*calendar_share_" . $type . " WHERE ((share = ? AND sharetype = 'user') " . $group_where . ") " . $permission_where); $result = $stmt->execute(array($share)); if($result->numRows() == 1){ return true; @@ -211,7 +211,7 @@ class OC_Calendar_Share{ */ public static function check_access($share, $id, $type){ $group_where = self::group_sql(OC_Group::getUserGroups($share)); - $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE (' . $type . 'id = ? AND (share = ? AND sharetype = "user") ' . $group_where . ')'); + $stmt = OCP\DB::prepare("SELECT * FROM *PREFIX*calendar_share_" . $type . " WHERE (" . $type . "id = ? AND (share = ? AND sharetype = 'user') " . $group_where . ")"); $result = $stmt->execute(array($id,$share)); $rows = $result->numRows(); if($rows > 0){ @@ -229,9 +229,9 @@ class OC_Calendar_Share{ * @return: mixed - bool if false, array with type and id if true */ public static function getElementByToken($token){ - $stmt_calendar = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::CALENDAR . ' WHERE sharetype = "public" AND share = ?'); + $stmt_calendar = OCP\DB::prepare("SELECT * FROM *PREFIX*calendar_share_" . OC_Calendar_Share::CALENDAR . " WHERE sharetype = 'public' AND share = ?"); $result_calendar = $stmt_calendar->execute(array($token)); - $stmt_event = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::EVENT . ' WHERE sharetype = "public" AND share = ?'); + $stmt_event = OCP\DB::prepare("SELECT * FROM *PREFIX*calendar_share_" . OC_Calendar_Share::EVENT . " WHERE sharetype = 'public' AND share = ?"); $result_event = $stmt_event->execute(array($token)); $return = array(); if($result_calendar->numRows() == 0 && $result_event->numRows() == 0){ @@ -253,7 +253,7 @@ class OC_Calendar_Share{ * @param (string) $ */ public static function set_active($share, $id, $active){ - $stmt = OCP\DB::prepare('UPDATE *PREFIX*calendar_share_calendar SET active = ? WHERE share = ? AND sharetype = "user" AND calendarid = ?'); + $stmt = OCP\DB::prepare("UPDATE *PREFIX*calendar_share_calendar SET active = ? WHERE share = ? AND sharetype = 'user' AND calendarid = ?"); $stmt->execute(array($active, $share, $id)); } }
\ No newline at end of file diff --git a/apps/calendar/settings.php b/apps/calendar/settings.php index 981df9ffafd..a18b1ca9f42 100755 --- a/apps/calendar/settings.php +++ b/apps/calendar/settings.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -$tmpl = new OC_Template( 'calendar', 'settings'); +$tmpl = new OCP\Template( 'calendar', 'settings'); $timezone=OCP\Config::getUserValue(OCP\USER::getUser(),'calendar','timezone',''); $tmpl->assign('timezone',$timezone); $tmpl->assign('timezones',DateTimeZone::listIdentifiers()); diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index af3b82a48fc..a140316ea07 100755 --- a/apps/calendar/templates/part.choosecalendar.php +++ b/apps/calendar/templates/part.choosecalendar.php @@ -5,7 +5,7 @@ $option_calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); for($i = 0; $i < count($option_calendars); $i++){ echo "<tr>"; - $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); + $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $option_calendars[$i]); if(OC_Calendar_Share::allUsersSharedwith($option_calendars[$i]['id'], OC_Calendar_Share::CALENDAR) == array()){ $shared = false; @@ -36,7 +36,7 @@ $count = count($share); for($i = 0; $i < $count; $i++){ $share[$i]['calendar'] = OC_Calendar_App::getCalendar($share[$i]['calendarid'], false, false); echo '<tr>'; - $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields.shared'); + $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields.shared'); $tmpl->assign('share', $share[$i]); $tmpl->printpage(); echo '</tr>'; diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php index 8848d228054..965523f847a 100755 --- a/apps/calendar/templates/part.choosecalendar.rowfields.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.php @@ -1,8 +1,8 @@ <?php echo '<td width="20px"><input id="active_' . $_['calendar']['id'] . '" type="checkbox" onClick="Calendar.UI.Calendar.activation(this,' . $_['calendar']['id'] . ')"' . ($_['calendar']['active'] ? ' checked="checked"' : '') . '></td>'; echo '<td id="' . OCP\USER::getUser() . '_' . $_['calendar']['id'] . '"><label for="active_' . $_['calendar']['id'] . '">' . $_['calendar']['displayname'] . '</label></td>'; -echo '<td width="20px"><a href="#" onclick="Calendar.UI.Share.dropdown(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['id'] . '\');" title="' . $l->t("Share Calendar") . '" class="action"><img class="svg action" src="' . ((!$_['shared']) ? '../../core/img/actions/share.svg' : '../../core/img/actions/shared.svg') . '"></a></td>'; -echo '<td width="20px"><a href="#" onclick="Calendar.UI.showCalDAVUrl(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['uri'] . '\');" title="' . $l->t("CalDav Link") . '" class="action"><img class="svg action" src="../../core/img/actions/public.svg"></a></td>'; -echo '<td width="20px"><a href="export.php?calid=' . $_['calendar']['id'] . '" title="' . $l->t('Download') . '" class="action"><img class="svg action" src="../../core/img/actions/download.svg"></a></td>'; -echo '<td width="20px"><a href="#" title="' . $l->t('Edit') . '" class="action" onclick="Calendar.UI.Calendar.edit(this, ' . $_['calendar']['id'] . ');"><img class="svg action" src="../../core/img/actions/rename.svg"></a></td>'; -echo '<td width="20px"><a href="#" onclick="Calendar.UI.Calendar.deleteCalendar(\'' . $_['calendar']['id'] . '\');" title="' . $l->t('Delete') . '" class="action"><img class="svg action" src="../../core/img/actions/delete.svg"></a></td>';
\ No newline at end of file +echo '<td width="20px"><a href="#" onclick="Calendar.UI.Share.dropdown(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['id'] . '\');" title="' . $l->t("Share Calendar") . '" class="action"><img class="svg action" src="' . ((!$_['shared']) ? OCP\Util::imagePath('core', 'actions/share.svg') : OCP\Util::imagePath('core', 'actions/shared.svg')) . '"></a></td>'; +echo '<td width="20px"><a href="#" onclick="Calendar.UI.showCalDAVUrl(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['uri'] . '\');" title="' . $l->t("CalDav Link") . '" class="action"><img class="svg action" src="'.OCP\Util::imagePath('core', 'actions/public.svg').'"></a></td>'; +echo '<td width="20px"><a href="?app=calendar&getfile=export.php?calid=' . $_['calendar']['id'] . '" title="' . $l->t('Download') . '" class="action"><img class="svg action" src="'.OCP\Util::imagePath('core', 'actions/download.svg').'"></a></td>'; +echo '<td width="20px"><a href="#" title="' . $l->t('Edit') . '" class="action" onclick="Calendar.UI.Calendar.edit(this, ' . $_['calendar']['id'] . ');"><img class="svg action" src="'.OCP\Util::imagePath('core', 'actions/rename.svg').'"></a></td>'; +echo '<td width="20px"><a href="#" onclick="Calendar.UI.Calendar.deleteCalendar(\'' . $_['calendar']['id'] . '\');" title="' . $l->t('Delete') . '" class="action"><img class="svg action" src="'.OCP\Util::imagePath('core', 'actions/delete.svg').'"></a></td>'; diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 9e54616190c..b3bbf7a375b 100644..100755 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -27,7 +27,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <th width="75px"><?php echo $l->t("Category");?>:</th> <td> <input id="category" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? htmlspecialchars($_['categories']) : '' ?>"> - <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a> + <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo OCP\image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a> </td> <?php if(count($_['calendar_options']) > 1) { ?> <th width="75px"> <?php echo $l->t("Calendar");?>:</th> @@ -35,7 +35,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <select style="width:140px;" name="calendar"> <?php if (!isset($_['calendar'])) {$_['calendar'] = false;} - echo html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname')); + echo OCP\html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname')); ?> </select> </td> @@ -101,7 +101,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <td> <select id="repeat" name="repeat"> <?php - echo html_select_options($_['repeat_options'], $_['repeat']); + echo OCP\html_select_options($_['repeat_options'], $_['repeat']); ?> </select></td> <td><input type="button" style="float:right;" class="submit" value="<?php echo $l->t("Advanced"); ?>" onclick="Calendar.UI.showadvancedoptionsforrepeating();" id="advanced_options_button"></td> @@ -114,7 +114,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <td> <select id="advanced_month_select" name="advanced_month_select"> <?php - echo html_select_options($_['repeat_month_options'], $_['repeat_month']); + echo OCP\html_select_options($_['repeat_month_options'], $_['repeat_month']); ?> </select> </td> @@ -126,7 +126,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <td> <select id="advanced_year_select" name="advanced_year_select"> <?php - echo html_select_options($_['repeat_year_options'], $_['repeat_year']); + echo OCP\html_select_options($_['repeat_year_options'], $_['repeat_year']); ?> </select> </td> @@ -138,7 +138,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <td id="weekofmonthcheckbox"> <select id="weekofmonthoptions" name="weekofmonthoptions"> <?php - echo html_select_options($_['repeat_weekofmonth_options'], $_['repeat_weekofmonth']); + echo OCP\html_select_options($_['repeat_weekofmonth_options'], $_['repeat_weekofmonth']); ?> </select> </td> @@ -151,7 +151,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <select id="weeklyoptions" name="weeklyoptions[]" multiple="multiple" style="width: 150px;" title="<?php echo $l->t("Select weekdays") ?>"> <?php if (!isset($_['weekdays'])) {$_['weekdays'] = array();} - echo html_select_options($_['repeat_weekly_options'], $_['repeat_weekdays'], array('combine'=>true)); + echo OCP\html_select_options($_['repeat_weekly_options'], $_['repeat_weekdays'], array('combine'=>true)); ?> </select> </td> @@ -164,7 +164,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <select id="byyearday" name="byyearday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>"> <?php if (!isset($_['repeat_byyearday'])) {$_['repeat_byyearday'] = array();} - echo html_select_options($_['repeat_byyearday_options'], $_['repeat_byyearday'], array('combine'=>true)); + echo OCP\html_select_options($_['repeat_byyearday_options'], $_['repeat_byyearday'], array('combine'=>true)); ?> </select><?php echo $l->t('and the events day of year.'); ?> </td> @@ -177,7 +177,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <select id="bymonthday" name="bymonthday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>"> <?php if (!isset($_['repeat_bymonthday'])) {$_['repeat_bymonthday'] = array();} - echo html_select_options($_['repeat_bymonthday_options'], $_['repeat_bymonthday'], array('combine'=>true)); + echo OCP\html_select_options($_['repeat_bymonthday_options'], $_['repeat_bymonthday'], array('combine'=>true)); ?> </select><?php echo $l->t('and the events day of month.'); ?> </td> @@ -190,7 +190,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <select id="bymonth" name="bymonth[]" multiple="multiple" title="<?php echo $l->t("Select months") ?>"> <?php if (!isset($_['repeat_bymonth'])) {$_['repeat_bymonth'] = array();} - echo html_select_options($_['repeat_bymonth_options'], $_['repeat_bymonth'], array('combine'=>true)); + echo OCP\html_select_options($_['repeat_bymonth_options'], $_['repeat_bymonth'], array('combine'=>true)); ?> </select> </td> @@ -203,7 +203,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <select id="byweekno" name="byweekno[]" multiple="multiple" title="<?php echo $l->t("Select weeks") ?>"> <?php if (!isset($_['repeat_byweekno'])) {$_['repeat_byweekno'] = array();} - echo html_select_options($_['repeat_byweekno_options'], $_['repeat_byweekno'], array('combine'=>true)); + echo OCP\html_select_options($_['repeat_byweekno_options'], $_['repeat_byweekno'], array('combine'=>true)); ?> </select><?php echo $l->t('and the events week of year.'); ?> </td> @@ -222,7 +222,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid <select id="end" name="end"> <?php if($_['repeat_end'] == '') $_['repeat_end'] = 'never'; - echo html_select_options($_['repeat_end_options'], $_['repeat_end']); + echo OCP\html_select_options($_['repeat_end_options'], $_['repeat_end']); ?> </select> </td> diff --git a/apps/calendar/templates/part.import.php b/apps/calendar/templates/part.import.php index 80375c3ef78..e93ea1af4c9 100755 --- a/apps/calendar/templates/part.import.php +++ b/apps/calendar/templates/part.import.php @@ -8,7 +8,7 @@ <?php $calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); $calendar_options[] = array('id'=>'newcal', 'displayname'=>$l->t('create a new calendar')); -echo html_select_options($calendar_options, $calendar_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); +echo OCP\html_select_options($calendar_options, $calendar_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); ?> </select> <div id="newcalform" style="display: none;"> diff --git a/apps/calendar/templates/part.showevent.php b/apps/calendar/templates/part.showevent.php index cad8bd27fb7..3646baf5bb7 100644..100755 --- a/apps/calendar/templates/part.showevent.php +++ b/apps/calendar/templates/part.showevent.php @@ -23,7 +23,7 @@ echo $l->t('No categories selected'); }else{ echo '<select id="category" name="categories[]" multiple="multiple" title="' . $l->t("Select category") . '">'; - echo html_select_options($_['categories'], $_['categories'], array('combine'=>true)); + echo OCP\html_select_options($_['categories'], $_['categories'], array('combine'=>true)); echo '</select>'; } ?> @@ -99,7 +99,7 @@ <td> <select id="repeat" name="repeat"> <?php - echo html_select_options(array($_['repeat_options'][$_['repeat']]), $_['repeat']); + echo OCP\html_select_options(array($_['repeat_options'][$_['repeat']]), $_['repeat']); ?> </select></td> <td><input type="button" style="float:right;" class="submit" value="<?php echo $l->t("Advanced"); ?>" onclick="Calendar.UI.showadvancedoptionsforrepeating();" id="advanced_options_button"></td> @@ -112,7 +112,7 @@ <td> <select id="advanced_month_select" name="advanced_month_select"> <?php - echo html_select_options(array($_['repeat_month_options'][$_['repeat_month']]), $_['repeat_month']); + echo OCP\html_select_options(array($_['repeat_month_options'][$_['repeat_month']]), $_['repeat_month']); ?> </select> </td> @@ -124,7 +124,7 @@ <td> <select id="advanced_year_select" name="advanced_year_select"> <?php - echo html_select_options(array($_['repeat_year_options'][$_['repeat_year']]), $_['repeat_year']); + echo OCP\html_select_options(array($_['repeat_year_options'][$_['repeat_year']]), $_['repeat_year']); ?> </select> </td> @@ -136,7 +136,7 @@ <td id="weekofmonthcheckbox"> <select id="weekofmonthoptions" name="weekofmonthoptions"> <?php - echo html_select_options(array($_['repeat_weekofmonth_options'][$_['repeat_weekofmonth']]), $_['repeat_weekofmonth']); + echo OCP\html_select_options(array($_['repeat_weekofmonth_options'][$_['repeat_weekofmonth']]), $_['repeat_weekofmonth']); ?> </select> </td> @@ -149,7 +149,7 @@ <select id="weeklyoptions" name="weeklyoptions[]" multiple="multiple" style="width: 150px;" title="<?php echo $l->t("Select weekdays") ?>"> <?php if (!isset($_['weekdays'])) {$_['weekdays'] = array();} - echo html_select_options(array($_['repeat_weekly_options'][$_['repeat_weekdays']]), $_['repeat_weekdays'], array('combine'=>true)); + echo OCP\html_select_options(array($_['repeat_weekly_options'][$_['repeat_weekdays']]), $_['repeat_weekdays'], array('combine'=>true)); ?> </select> </td> @@ -162,7 +162,7 @@ <select id="byyearday" name="byyearday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>"> <?php if (!isset($_['repeat_byyearday'])) {$_['repeat_byyearday'] = array();} - echo html_select_options(array($_['repeat_byyearday_options'][$_['repeat_byyearday']]), $_['repeat_byyearday'], array('combine'=>true)); + echo OCP\html_select_options(array($_['repeat_byyearday_options'][$_['repeat_byyearday']]), $_['repeat_byyearday'], array('combine'=>true)); ?> </select><?php echo $l->t('and the events day of year.'); ?> </td> @@ -175,7 +175,7 @@ <select id="bymonthday" name="bymonthday[]" multiple="multiple" title="<?php echo $l->t("Select days") ?>"> <?php if (!isset($_['repeat_bymonthday'])) {$_['repeat_bymonthday'] = array();} - echo html_select_options(array($_['repeat_bymonthday_options'][$_['repeat_bymonthday']]), $_['repeat_bymonthday'], array('combine'=>true)); + echo OCP\html_select_options(array($_['repeat_bymonthday_options'][$_['repeat_bymonthday']]), $_['repeat_bymonthday'], array('combine'=>true)); ?> </select><?php echo $l->t('and the events day of month.'); ?> </td> @@ -188,7 +188,7 @@ <select id="bymonth" name="bymonth[]" multiple="multiple" title="<?php echo $l->t("Select months") ?>"> <?php if (!isset($_['repeat_bymonth'])) {$_['repeat_bymonth'] = array();} - echo html_select_options(array($_['repeat_bymonth_options'][$_['repeat_bymonth']]), $_['repeat_bymonth'], array('combine'=>true)); + echo OCP\html_select_options(array($_['repeat_bymonth_options'][$_['repeat_bymonth']]), $_['repeat_bymonth'], array('combine'=>true)); ?> </select> </td> @@ -201,7 +201,7 @@ <select id="byweekno" name="byweekno[]" multiple="multiple" title="<?php echo $l->t("Select weeks") ?>"> <?php if (!isset($_['repeat_byweekno'])) {$_['repeat_byweekno'] = array();} - echo html_select_options(array($_['repeat_byweekno_options'][$_['repeat_byweekno']]), $_['repeat_byweekno'], array('combine'=>true)); + echo OCP\html_select_options(array($_['repeat_byweekno_options'][$_['repeat_byweekno']]), $_['repeat_byweekno'], array('combine'=>true)); ?> </select><?php echo $l->t('and the events week of year.'); ?> </td> @@ -220,7 +220,7 @@ <select id="end" name="end"> <?php if($_['repeat_end'] == '') $_['repeat_end'] = 'never'; - echo html_select_options(array($_['repeat_end_options'][$_['repeat_end']]), $_['repeat_end']); + echo OCP\html_select_options(array($_['repeat_end_options'][$_['repeat_end']]), $_['repeat_end']); ?> </select> </td> diff --git a/apps/calendar/templates/share.dropdown.php b/apps/calendar/templates/share.dropdown.php index b11a4ef94cf..e0dabebf257 100755 --- a/apps/calendar/templates/share.dropdown.php +++ b/apps/calendar/templates/share.dropdown.php @@ -28,7 +28,7 @@ foreach($allocusers as $ocuser){ } unset($allusers[OCP\USER::getUser()]); $allusers = array_flip($allusers); -echo html_select_options($allusers, array()); +echo OCP\html_select_options($allusers, array()); ?> </select><br> <ul id="sharewithuser_list"> @@ -54,7 +54,7 @@ $allgroups = array(); foreach($allocgroups as $ocgroup){ $allgroups[$ocgroup] = $ocgroup; } -echo html_select_options($allgroups, array()); +echo OCP\html_select_options($allgroups, array()); ?> </select><br> <ul id="sharewithgroup_list"> diff --git a/apps/contacts/ajax/addbook.php b/apps/contacts/ajax/addbook.php index 254af1c3f50..70f47cc8123 100755 --- a/apps/contacts/ajax/addbook.php +++ b/apps/contacts/ajax/addbook.php @@ -13,7 +13,7 @@ $book = array( 'id' => 'new', 'displayname' => '', ); -$tmpl = new OC_Template('contacts', 'part.editaddressbook'); +$tmpl = new OCP\Template('contacts', 'part.editaddressbook'); $tmpl->assign('new', true); $tmpl->assign('addressbook', $book); $tmpl->printPage(); diff --git a/apps/contacts/ajax/chooseaddressbook.php b/apps/contacts/ajax/chooseaddressbook.php index 2fe55606d1d..9088a4e9d7d 100755 --- a/apps/contacts/ajax/chooseaddressbook.php +++ b/apps/contacts/ajax/chooseaddressbook.php @@ -10,5 +10,5 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -$output = new OC_TEMPLATE("contacts", "part.chooseaddressbook"); +$output = new OCP\Template("contacts", "part.chooseaddressbook"); $output -> printpage(); diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index 93e618a0800..37d396cd83a 100755 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -12,7 +12,7 @@ OCP\JSON::checkAppEnabled('contacts'); $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser()); $contacts = OC_Contacts_VCard::all($ids); -$tmpl = new OC_TEMPLATE("contacts", "part.contacts"); +$tmpl = new OCP\Template("contacts", "part.contacts"); $tmpl->assign('contacts', $contacts); $page = $tmpl->fetchPage(); diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index 772232b67d7..af7c19eef51 100755 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -32,7 +32,7 @@ if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { //exit(); } $addressbook = OC_Contacts_App::getAddressbook($bookid); -$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); +$tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $addressbook); OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), diff --git a/apps/contacts/ajax/cropphoto.php b/apps/contacts/ajax/cropphoto.php index 125dd107602..7b286dbdb52 100755 --- a/apps/contacts/ajax/cropphoto.php +++ b/apps/contacts/ajax/cropphoto.php @@ -30,7 +30,7 @@ OCP\JSON::checkAppEnabled('contacts'); $tmp_path = $_GET['tmp_path']; $id = $_GET['id']; OCP\Util::writeLog('contacts','ajax/cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG); -$tmpl = new OC_TEMPLATE("contacts", "part.cropphoto"); +$tmpl = new OCP\Template("contacts", "part.cropphoto"); $tmpl->assign('tmp_path', $tmp_path); $tmpl->assign('id', $id); $page = $tmpl->fetchPage(); diff --git a/apps/contacts/ajax/editaddress.php b/apps/contacts/ajax/editaddress.php index 4044eb5a359..9fb35a0b5f7 100755 --- a/apps/contacts/ajax/editaddress.php +++ b/apps/contacts/ajax/editaddress.php @@ -15,7 +15,7 @@ $checksum = isset($_GET['checksum'])?$_GET['checksum']:''; $vcard = OC_Contacts_App::getContactVCard($id); $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); -$tmpl = new OC_TEMPLATE("contacts", "part.edit_address_dialog"); +$tmpl = new OCP\Template("contacts", "part.edit_address_dialog"); if($checksum) { $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); $element = $vcard->children[$line]; diff --git a/apps/contacts/ajax/editaddressbook.php b/apps/contacts/ajax/editaddressbook.php index fe1806a7b8a..7a9b757ae0d 100755 --- a/apps/contacts/ajax/editaddressbook.php +++ b/apps/contacts/ajax/editaddressbook.php @@ -10,7 +10,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']); -$tmpl = new OC_Template("contacts", "part.editaddressbook"); +$tmpl = new OCP\Template("contacts", "part.editaddressbook"); $tmpl->assign('new', false); $tmpl->assign('addressbook', $addressbook); $tmpl->printPage(); diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php index 155bee70a7f..dc64eeb5101 100755 --- a/apps/contacts/ajax/editname.php +++ b/apps/contacts/ajax/editname.php @@ -18,7 +18,7 @@ function debug($msg) { OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG); } -$tmpl = new OC_TEMPLATE("contacts", "part.edit_name_dialog"); +$tmpl = new OCP\Template("contacts", "part.edit_name_dialog"); $id = isset($_GET['id'])?$_GET['id']:''; debug('id: '.$id); diff --git a/apps/contacts/ajax/importaddressbook.php b/apps/contacts/ajax/importaddressbook.php index 66cfa4f8af4..f93bbfa4d9d 100755 --- a/apps/contacts/ajax/importaddressbook.php +++ b/apps/contacts/ajax/importaddressbook.php @@ -16,7 +16,7 @@ $freeSpace=OC_Filesystem::free_space('/'); $freeSpace=max($freeSpace,0); $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); -$tmpl = new OC_Template('contacts', 'part.importaddressbook'); +$tmpl = new OCP\Template('contacts', 'part.importaddressbook'); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->printpage(); diff --git a/apps/contacts/ajax/importdialog.php b/apps/contacts/ajax/importdialog.php index 7a564ccec83..5f8805a6106 100755 --- a/apps/contacts/ajax/importdialog.php +++ b/apps/contacts/ajax/importdialog.php @@ -9,7 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); -$tmpl = new OC_Template('contacts', 'part.import'); +$tmpl = new OCP\Template('contacts', 'part.import'); $tmpl->assign('path', $_POST['path']); $tmpl->assign('filename', $_POST['filename']); $tmpl->printpage(); diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php index 047db4d940c..4e6f2206fef 100755 --- a/apps/contacts/ajax/loadcard.php +++ b/apps/contacts/ajax/loadcard.php @@ -49,7 +49,7 @@ $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL'); -$tmpl = new OC_Template('contacts','part.contact'); +$tmpl = new OCP\Template('contacts','part.contact'); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('adr_types',$adr_types); diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php index 8ad828ebba3..6e8fcc4b049 100755 --- a/apps/contacts/ajax/loadintro.php +++ b/apps/contacts/ajax/loadintro.php @@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -$tmpl = new OC_Template('contacts','part.no_contacts'); +$tmpl = new OCP\Template('contacts','part.no_contacts'); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php index 9913fe13e11..ef429e82891 100755 --- a/apps/contacts/ajax/loadphoto.php +++ b/apps/contacts/ajax/loadphoto.php @@ -53,7 +53,7 @@ foreach($vcard->children as $property){ } } -$tmpl = new OC_TEMPLATE("contacts", "part.contactphoto"); +$tmpl = new OCP\Template("contacts", "part.contactphoto"); $tmpl->assign('id', $id); if($refresh) { $tmpl->assign('refresh', 1); diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php index 5418e26cd10..cd470307125 100755 --- a/apps/contacts/ajax/savecrop.php +++ b/apps/contacts/ajax/savecrop.php @@ -101,7 +101,7 @@ if(file_exists($tmp_path)) { } unlink($tmpfname); //$result=array( "status" => "success", 'mime'=>$image->mimeType(), 'tmp'=>$tmp_path); - $tmpl = new OC_TEMPLATE("contacts", "part.contactphoto"); + $tmpl = new OCP\Template("contacts", "part.contactphoto"); $tmpl->assign('tmp_path', $tmpfname); $tmpl->assign('mime', $image->mimeType()); $tmpl->assign('id', $id); diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index 13f1c15ac23..19b5b3bddce 100755 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -35,7 +35,7 @@ if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { } $addressbook = OC_Contacts_App::getAddressbook($bookid); -$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); +$tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $addressbook); OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), diff --git a/apps/contacts/appinfo/info.xml b/apps/contacts/appinfo/info.xml index 55ddf42ccc1..4d2fe383723 100644 --- a/apps/contacts/appinfo/info.xml +++ b/apps/contacts/appinfo/info.xml @@ -6,5 +6,6 @@ <author>Jakob Sack</author> <require>2</require> <description>Address book with CardDAV support.</description> + <standalone/> <default_enable/> </info> diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css index 04afe44b2cc..c247ecf5680 100644 --- a/apps/contacts/css/contacts.css +++ b/apps/contacts/css/contacts.css @@ -1,9 +1,9 @@ /*dl > dt { font-weight: bold; }*/ -#leftcontent { top: 3.5em !important; } +#leftcontent { top: 3.5em !important; padding: 0; margin: 0; } #rightcontent { top: 3.5em !important; padding-top: 5px; } -#contacts { background: #fff; width: 20em; top: 3.7em; bottom:3em; position: fixed; overflow: auto; } +#contacts { background: #fff; width: 20em; left: 12.5em; top: 3.7em; bottom:3em; position: fixed; overflow: auto; padding: 0; margin: 0; } #bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 0 0 #000, -3px 0 7px #000; -webkit-box-shadow: 0 0 0 #000, -3px 0 7px #000; box-shadow: 0 0 0 #000, -3px 0 7px #000;} #contacts_newcontact { float: left; margin: 0.2em 0 0 1em; } #chooseaddressbook { float: right; margin: 0.2em 1em 0 0; } @@ -25,10 +25,7 @@ #card input[type="text"].contacts_property,input[type="email"].contacts_property { width: 14em; float: left; font-weight: bold; } .categories { float: left; width: 16em; } #card input[type="text"],input[type="email"],input[type="tel"],input[type="date"], select, textarea { background-color: #fefefe; border: 0 !important; -webkit-appearance:none !important; -moz-appearance:none !important; -webkit-box-sizing:none !important; -moz-box-sizing:none !important; box-sizing:none !important; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; float: left; } -#card input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,input[type="email"]:hover,input[type="tel"]:hover,input[type="date"]:hover,input[type="date"],input[type="date"]:hover,input[type="date"]:active,input[type="date"]:active,input[type="date"]:active,input[type="email"]:active,input[type="tel"]:active, select:hover, select:focus, select:active { border: 0 !important; -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #ddd, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; float: left; } - -textarea:focus, textarea:hover { background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #ddd, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; float: left; } -input[type="text"]:invalid,input[type="email"]:invalid,input[type="tel"]:invalid,input[type="date"]:invalid, textarea:invalid { color: #bbb !important; } +#card input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,input[type="email"]:hover,input[type="tel"]:hover,input[type="date"]:hover,input[type="date"],input[type="date"]:hover,input[type="date"]:active,input[type="date"]:active,input[type="date"]:active,input[type="email"]:active,input[type="tel"]:active, select:hover, select:focus, select:active, textarea:focus, textarea:hover { border: 0 !important; -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #ddd, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; float: left; } textarea { width: 80%; min-height: 5em; min-width: 30em; margin: 0 !important; padding: 0 !important; outline: 0 !important;} dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; } .form dt { display: table-cell; clear: left; float: left; width: 7em; margin: 0; padding: 0.8em 0.5em 0 0; text-align:right; text-overflow:ellipsis; o-text-overflow: ellipsis; vertical-align: text-bottom; color: #bbb;/* white-space: pre-wrap; white-space: -moz-pre-wrap !important; white-space: -pre-wrap; white-space: -o-pre-wrap;*/ } @@ -101,7 +98,8 @@ input[type="checkbox"] { width: 20px; height: 20px; vertical-align: bottom; } .propertycontainer dd { float: left; width: 25em; } .propertylist { clear: none; max-width: 28em; } .propertylist li.propertycontainer { white-space: nowrap; min-width: 35em; /*max-width: 30em;*/ display: block; clear: right; } -.propertylist li > input[type="text"],input[type="email"],input[type="tel"] { float: left; max-width: 15em; } +.propertycontainer[data-element="EMAIL"] > input[type="email"] { min-width: 19em !important; float: left; } +.propertycontainer[data-element="TEL"] > input[type="text"] { width: 10em !important; float: left; } .propertylist li > input[type="checkbox"],input[type="radio"] { float: left; clear: left; width: 20px; height: 20px; vertical-align: middle; } .propertylist li > select { float: left; max-width: 8em; } .typelist { float: left; max-width: 10em; border: 0; background-color: #fff; } /* for multiselect */ diff --git a/apps/contacts/img/contact-new.png b/apps/contacts/img/contact-new.png Binary files differindex 3d0970ddd4c..087ad9ab2d3 100644 --- a/apps/contacts/img/contact-new.png +++ b/apps/contacts/img/contact-new.png diff --git a/apps/contacts/img/contact-new.svg b/apps/contacts/img/contact-new.svg index f4ab2981674..8322414dac3 100644 --- a/apps/contacts/img/contact-new.svg +++ b/apps/contacts/img/contact-new.svg @@ -7,10 +7,34 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" - width="16" - height="16" - id="svg3796"> + width="20" + height="20" + id="svg3796" + inkscape:version="0.48.2 r9819" + sodipodi:docname="contact-new.svg"> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="640" + inkscape:window-height="480" + id="namedview18" + showgrid="false" + inkscape:zoom="11.8" + inkscape:cx="10" + inkscape:cy="10" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="svg3796" /> <defs id="defs3798"> <linearGradient @@ -29,12 +53,13 @@ <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> + <dc:title /> </cc:Work> </rdf:RDF> </metadata> <g - id="layer1"> + id="layer1" + transform="matrix(1.2460746,0,0,1.2420314,-0.12303732,-0.51608095)"> <g transform="matrix(1.0633871,0,0,1.0633871,-0.03169354,-0.53733376)" id="g4344"> @@ -97,7 +122,8 @@ <path d="m 10.823783,8.4435567 1.999999,0 0,1.9999993 2,0 0,2 -2,0 0,2 -1.999999,0 0,-2 -2.0000004,0 0,-2 2.0000004,0 z" id="path4336" - style="fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + style="fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + inkscape:connector-curvature="0" /> </g> </g> </svg> diff --git a/apps/contacts/index.php b/apps/contacts/index.php index 69e7d57309f..74b7c43c556 100755 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -58,7 +58,7 @@ OCP\Util::addStyle('contacts','jquery.combobox'); OCP\Util::addStyle('contacts','jquery.Jcrop'); OCP\Util::addStyle('contacts','contacts'); -$tmpl = new OC_Template( "contacts", "index", "user" ); +$tmpl = new OCP\Template( "contacts", "index", "user" ); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('property_types', $property_types); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 68a01174d83..44b29792206 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -168,14 +168,14 @@ Contacts={ honsuf:'', data:undefined, update:function(id) { - // Make sure proper DOM is loaded. var newid; if(id == undefined) { newid = $('#contacts li:first-child').data('id'); } else { newid = id; } - if(!$('n')) { + // Make sure proper DOM is loaded. + if(!$('#card')) { $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){ if(jsondata.status == 'success'){ $('#rightcontent').html(jsondata.data.page); @@ -185,8 +185,6 @@ Contacts={ }); } if($('#contacts li').length > 0) { - //var newid = $('#contacts li:first-child').data('id'); - //$('#contacts li:first-child').addClass('active'); $('#leftcontent li[data-id="'+newid+'"]').addClass('active'); $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){ if(jsondata.status == 'success'){ @@ -210,8 +208,6 @@ Contacts={ }, doExport:function() { document.location.href = OC.linkTo('contacts', 'export.php') + '?contactid=' + this.id; - //$.get(OC.linkTo('contacts', 'export.php'),{'contactid':this.id},function(jsondata){ - //}); }, doImport:function(){ Contacts.UI.notImplemented(); @@ -249,7 +245,7 @@ Contacts={ if(!added) { $('#leftcontent ul').append(item); } - if(isnew) { + if(isnew) { // add some default properties Contacts.UI.Card.addProperty('EMAIL'); Contacts.UI.Card.addProperty('TEL'); Contacts.UI.Card.addProperty('NICKNAME'); @@ -261,7 +257,6 @@ Contacts={ } else{ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); - //alert(jsondata.data.message); } }); $('#contact_identity').show(); @@ -291,11 +286,10 @@ Contacts={ newid = newlistitem.data('id'); } $('#rightcontent').data('id',newid); - //$('#rightcontent').empty(); this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = ''; this.data = undefined; - // Load first in list. - if($('#contacts li').length > 0) { + + if($('#contacts li').length > 0) { // Load first in list. Contacts.UI.Card.update(newid); } else { // load intro page @@ -313,7 +307,6 @@ Contacts={ } else{ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); - //alert(jsondata.data.message); } }); } @@ -321,7 +314,6 @@ Contacts={ return false; }, loadContact:function(jsondata){ - //$('#contact_communication').hide(); this.data = jsondata; this.id = this.data.id; $('#rightcontent').data('id',this.id); @@ -508,7 +500,6 @@ Contacts={ } }, saveProperty:function(obj){ - // I couldn't get the selector to filter on 'contacts_property' so I filter by hand here :-/ if(!$(obj).hasClass('contacts_property')) { return false; } @@ -569,7 +560,6 @@ Contacts={ } }, addProperty:function(type){ - //console.log('addProperty:' + type); switch (type) { case 'PHOTO': this.loadPhoto(true); @@ -617,7 +607,6 @@ Contacts={ deleteProperty:function(obj, type){ Contacts.UI.loading(obj, true); var checksum = Contacts.UI.checksumFor(obj); - //console.log('deleteProperty, id: ' + this.id + ', checksum: ' + checksum); if(checksum) { $.getJSON(OC.filePath('contacts', 'ajax', 'deleteproperty.php'),{'id': this.id, 'checksum': checksum },function(jsondata){ if(jsondata.status == 'success'){ @@ -822,16 +811,13 @@ Contacts={ if(isnew) { container.remove(); } - //Contacts.UI.showHideContactInfo(); } }, close : function(event, ui) { - //alert('close'); $(this).dialog('destroy').remove(); if(isnew) { container.remove(); } - //Contacts.UI.showHideContactInfo(); }, open : function(event, ui) { $( "#adr_city" ).autocomplete({ @@ -848,9 +834,6 @@ Contacts={ }, success: function( data ) { response( $.map( data.geonames, function( item ) { - /*for(var key in item) { - console.log(key + ': ' + item[key]); - }*/ return { label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, value: item.name, @@ -865,9 +848,6 @@ Contacts={ if(ui.item && $('#adr_country').val().trim().length == 0) { $('#adr_country').val(ui.item.country); } - /*log( ui.item ? - "Selected: " + ui.item.label : - "Nothing selected, input was " + this.value);*/ }, open: function() { $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); @@ -892,9 +872,6 @@ Contacts={ }, success: function( data ) { response( $.map( data.geonames, function( item ) { - //for(var key in item) { - // console.log(key + ': ' + item[key]); - //} return { label: item.name, value: item.name @@ -1245,12 +1222,9 @@ Contacts={ function(jsondata) { if (jsondata.status == 'success'){ $(obj).closest('tr').remove(); - //$('#chooseaddressbook_dialog').dialog('destroy').remove(); Contacts.UI.Contacts.update(); - //Contacts.UI.Addressbooks.overview(); } else { OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); - //alert('Error: ' + data.message); } }); } @@ -1480,7 +1454,6 @@ $(document).ready(function(){ } else{ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); - //alert(jsondata.data.message); } }); return false; @@ -1507,9 +1480,6 @@ $(document).ready(function(){ } }); - // NOTE: For some reason the selector doesn't work when I select by '.contacts_property' too... - // I do the filtering in the event handler instead. - //$('input[type="text"],input[type="checkbox"],input[type="email"],input[type="tel"],input[type="date"], select').live('change', function(){ $('.contacts_property').live('change', function(){ Contacts.UI.Card.saveProperty(this); }); @@ -1523,7 +1493,7 @@ $(document).ready(function(){ }); // Name has changed. Update it and reorder. - $('#fn').live('change',function(){ + $('#fn').change(function(){ var name = $('#fn').val(); var item = $('#contacts [data-id="'+Contacts.UI.Card.id+'"]').clone(); $('#contacts [data-id="'+Contacts.UI.Card.id+'"]').remove(); @@ -1541,9 +1511,7 @@ $(document).ready(function(){ } }); - /** - * Profile picture upload handling - */ + // Profile picture upload handling // New profile picture selected $('#file_upload_start').change(function(){ Contacts.UI.Card.uploadPhoto(this.files); @@ -1594,30 +1562,22 @@ $(document).ready(function(){ OC.dialogs.alert(xhr.status + ': ' + xhr.responseText, t('contacts', 'Error')); } } else { - //alert(xhr.responseText); OC.dialogs.alert(response.data.message, t('contacts', 'Error')); } - // stop loading indicator - //$('#contacts_details_photo_progress').hide(); } }; fileUpload.onprogress = function(e){ if (e.lengthComputable){ var _progress = Math.round((e.loaded * 100) / e.total); - if (_progress != 100){ - //$('#contacts_details_photo_progress').text(_progress + '%'); - //$('#contacts_details_photo_progress').val(_progress); - } + //if (_progress != 100){ + //} } }; - // Start loading indicator. - //$('#contacts_details_photo_progress').show()(); xhr.open('POST', OC.filePath('contacts', 'ajax', 'uploadphoto.php')+'?id='+Contacts.UI.Card.id+'&imagefile='+encodeURIComponent(file.name), true); xhr.setRequestHeader('Cache-Control', 'no-cache'); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.setRequestHeader('X_FILE_NAME', encodeURIComponent(file.name)); - //xhr.setRequestHeader("X_FILENAME", file.name); xhr.setRequestHeader('X-File-Size', file.size); xhr.setRequestHeader('Content-Type', file.type); xhr.send(file); diff --git a/apps/contacts/settings.php b/apps/contacts/settings.php index b88128823a7..c88fed0b4d6 100644..100755 --- a/apps/contacts/settings.php +++ b/apps/contacts/settings.php @@ -1,6 +1,6 @@ <?php -$tmpl = new OC_Template( 'contacts', 'settings'); +$tmpl = new OCP\Template( 'contacts', 'settings'); return $tmpl->fetchPage(); ?> diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index 79825067d82..c28b47e7c28 100755 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -8,12 +8,12 @@ <?php echo $this->inc("part.contacts"); ?> </ul> </div> - <div id="bottomcontrols"> - <form> - <button class="svg" id="contacts_newcontact" title="<?php echo $l->t('Add Contact'); ?>"><img class="svg" src="<?php echo OCP\Util::linkTo('contacts', 'img/contact-new.svg'); ?>" alt="<?php echo $l->t('Add Contact'); ?>" /></button> - <button class="svg" id="chooseaddressbook" title="<?php echo $l->t('Addressbooks'); ?>"><img class="svg" src="core/img/actions/settings.svg" alt="<?php echo $l->t('Addressbooks'); ?>" /></button> - </form> - </div> +<div id="bottomcontrols"> + <form> + <button class="svg" id="contacts_newcontact" title="<?php echo $l->t('Add Contact'); ?>"><img class="svg" src="<?php echo OCP\Util::linkTo('contacts', 'img/contact-new.svg'); ?>" alt="<?php echo $l->t('Add Contact'); ?>" /></button> + <button class="svg" id="chooseaddressbook" title="<?php echo $l->t('Addressbooks'); ?>"><img class="svg" src="core/img/actions/settings.svg" alt="<?php echo $l->t('Addressbooks'); ?>" /></button> + </form> +</div> <div id="rightcontent" class="rightcontent" data-id="<?php echo $_['id']; ?>"> <?php if ($_['id']){ diff --git a/apps/contacts/templates/part.chooseaddressbook.php b/apps/contacts/templates/part.chooseaddressbook.php index 91b2f51c3b4..a0ec053ab91 100755 --- a/apps/contacts/templates/part.chooseaddressbook.php +++ b/apps/contacts/templates/part.chooseaddressbook.php @@ -4,7 +4,7 @@ $option_addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser()); for($i = 0; $i < count($option_addressbooks); $i++){ echo "<tr>"; - $tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); + $tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $option_addressbooks[$i]); $tmpl->assign('active', OC_Contacts_Addressbook::isActive($option_addressbooks[$i]['id'])); $tmpl->printpage(); diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index 4c23dac783b..74522be37c4 100755 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -55,7 +55,7 @@ $id = isset($_['id']) ? $_['id'] : ''; <input type="checkbox" class="contacts_property tip" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" /> <input type="email" required="required" class="nonempty contacts_property" name="value" value="" x-moz-errormessage="<?php echo $l->t('Please specify a valid email address.'); ?>" placeholder="<?php echo $l->t('Enter email address'); ?>" /> <select class="hidden" multiple="multiple" name="parameters[TYPE][]"> - <?php echo html_select_options($_['email_types'], array()) ?> + <?php echo OCP\html_select_options($_['email_types'], array()) ?> </select> <span class="listactions"><a class="action mail" title="<?php echo $l->t('Mail to address'); ?>"></a> <a role="button" class="action delete" title="<?php echo $l->t('Delete email address'); ?>"></a></span></li> @@ -69,7 +69,7 @@ $id = isset($_['id']) ? $_['id'] : ''; <input type="checkbox" class="contacts_property tip" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" /> <input type="text" required="required" class="nonempty contacts_property" name="value" value="" placeholder="<?php echo $l->t('Enter phone number'); ?>" /> <select multiple="multiple" name="parameters[TYPE][]"> - <?php echo html_select_options($_['phone_types'], array()) ?> + <?php echo OCP\html_select_options($_['phone_types'], array()) ?> </select> <a role="button" class="action delete" title="<?php echo $l->t('Delete phone number'); ?>"></a></li> </ul> diff --git a/apps/contacts/templates/part.edit_address_dialog.php b/apps/contacts/templates/part.edit_address_dialog.php index 507a3acaa0c..8b3425033cc 100644..100755 --- a/apps/contacts/templates/part.edit_address_dialog.php +++ b/apps/contacts/templates/part.edit_address_dialog.php @@ -15,7 +15,7 @@ foreach(isset($adr['parameters']['TYPE'])?array($adr['parameters']['TYPE']):arra </dt> <dd> <select id="adr_type" name="parameters[ADR][TYPE]" size="1"> - <?php echo html_select_options($_['adr_types'], $types) ?> + <?php echo OCP\html_select_options($_['adr_types'], $types) ?> </select> </dd> <dt> diff --git a/apps/contacts/templates/part.edit_name_dialog.php b/apps/contacts/templates/part.edit_name_dialog.php index bb774b62bd7..be45f9a5b06 100644..100755 --- a/apps/contacts/templates/part.edit_name_dialog.php +++ b/apps/contacts/templates/part.edit_name_dialog.php @@ -16,7 +16,7 @@ $addressbooks = isset($_['addressbooks'])?$_['addressbooks']:null; <dt><label for="addressbook"><?php echo $l->t('Addressbook'); ?></label></dt> <dd> <select id="aid" name="aid" size="1"> - <?php echo html_select_options($_['addressbooks'], null, array('value'=>'id', 'label'=>'displayname')); ?> + <?php echo OCP\html_select_options($_['addressbooks'], null, array('value'=>'id', 'label'=>'displayname')); ?> </select> </dd> <?php }} ?> diff --git a/apps/contacts/templates/part.import.php b/apps/contacts/templates/part.import.php index a2f8aefa6f4..2dac7dd0ca1 100755 --- a/apps/contacts/templates/part.import.php +++ b/apps/contacts/templates/part.import.php @@ -8,7 +8,7 @@ <?php $contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser()); $contacts_options[] = array('id'=>'newaddressbook', 'displayname'=>$l->t('create a new addressbook')); -echo html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); +echo OCP\html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); ?> </select> <div id="newaddressbookform" style="display: none;"> diff --git a/apps/contacts/templates/part.importaddressbook.php b/apps/contacts/templates/part.importaddressbook.php index 9a13ba1b0cd..a055dd60356 100755 --- a/apps/contacts/templates/part.importaddressbook.php +++ b/apps/contacts/templates/part.importaddressbook.php @@ -14,7 +14,7 @@ <select id="book" name="book" class="float"> <?php $contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser()); - echo html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); + echo OCP\html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); ?> </select> <span id="import_drop_target" class="droptarget float"><?php echo $l->t("Drop a VCF file to import contacts."); ?> (Max. <?php echo $_['uploadMaxHumanFilesize']; ?>)</span> diff --git a/apps/external/index.php b/apps/external/index.php index f1f6cbac3cf..d63be3ad1d5 100755 --- a/apps/external/index.php +++ b/apps/external/index.php @@ -35,7 +35,7 @@ if (isset($_GET['id'])) { $url = $sites[$id - 1][1]; OCP\App::setActiveNavigationEntry('external_index' . $id); - $tmpl = new OC_Template('external', 'frame', 'user'); + $tmpl = new OCP\Template('external', 'frame', 'user'); $tmpl->assign('url', $url); $tmpl->printPage(); } diff --git a/apps/external/settings.php b/apps/external/settings.php index c1a4242c333..c109733e548 100755 --- a/apps/external/settings.php +++ b/apps/external/settings.php @@ -4,7 +4,7 @@ OCP\User::checkAdminUser(); OCP\Util::addscript( "external", "admin" ); -$tmpl = new OC_Template( 'external', 'settings'); +$tmpl = new OCP\Template( 'external', 'settings'); return $tmpl->fetchPage(); ?> diff --git a/apps/external/templates/settings.php b/apps/external/templates/settings.php index a130477d465..b8139727eb6 100644..100755 --- a/apps/external/templates/settings.php +++ b/apps/external/templates/settings.php @@ -8,7 +8,7 @@ for($i = 0; $i < sizeof($sites); $i++) { echo '<li><input type="text" name="site_name[]" class="site_name" value="'.$sites[$i][0].'" placeholder="'.$l->t('Name').'" /> <input type="text" class="site_url" name="site_url[]" value="'.$sites[$i][1].'" placeholder="'.$l->t('URL').'" /> - <img class="svg action delete_button" src="'.image_path("", "actions/delete.svg") .'" title="'.$l->t("Remove site").'" /> + <img class="svg action delete_button" src="'.OCP\image_path("", "actions/delete.svg") .'" title="'.$l->t("Remove site").'" /> </li>'; } ?> diff --git a/apps/files/admin.php b/apps/files/admin.php index a59a73f0a5b..b0c2b35c696 100755 --- a/apps/files/admin.php +++ b/apps/files/admin.php @@ -51,7 +51,7 @@ $allowZipDownload = intval(OCP\Config::getSystemValue('allowZipDownload', true)) OCP\App::setActiveNavigationEntry( "files_administration" ); -$tmpl = new OC_Template( 'files', 'admin' ); +$tmpl = new OCP\Template( 'files', 'admin' ); $tmpl->assign( 'htaccessWorking', $htaccessWorking ); $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign( 'maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX)); diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 520e54e708d..ceb8d158580 100755 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -24,7 +24,7 @@ if($doBreadcrumb){ } } - $breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" ); + $breadcrumbNav = new OCP\Template( "files", "part.breadcrumb", "" ); $breadcrumbNav->assign( "breadcrumb", $breadcrumb ); $data['breadcrumb'] = $breadcrumbNav->fetchPage(); @@ -37,7 +37,7 @@ foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ $files[] = $i; } -$list = new OC_Template( "files", "part.list", "" ); +$list = new OCP\Template( "files", "part.list", "" ); $list->assign( "files", $files ); $data = array('files' => $list->fetchPage()); diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php index 36dd35cc73e..6e7ace91013 100755 --- a/apps/files/ajax/rawlist.php +++ b/apps/files/ajax/rawlist.php @@ -17,7 +17,7 @@ $mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : ''; $files = array(); foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){ $i["date"] = OCP\Util::formatDate($i["mtime"] ); - $i['mimetype_icon'] = $i['type'] == 'dir' ? mimetype_icon('dir'): mimetype_icon($i['mimetype']); + $i['mimetype_icon'] = $i['type'] == 'dir' ? OCP\mimetype_icon('dir'): OCP\mimetype_icon($i['mimetype']); $files[] = $i; } diff --git a/apps/files/appinfo/info.xml b/apps/files/appinfo/info.xml index 2abf54e7da6..03076dee98c 100644 --- a/apps/files/appinfo/info.xml +++ b/apps/files/appinfo/info.xml @@ -6,5 +6,6 @@ <licence>AGPL</licence> <author>Robin Appelman</author> <require>2</require> + <standalone/> <default_enable/> </info> diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index 0f618c391ad..94ae101bb00 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -22,11 +22,9 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ - // only need filesystem apps $RUNTIME_APPTYPES=array('filesystem','authentication'); - - +require_once('../lib/base.php'); // Backends $authBackend = new OC_Connector_Sabre_Auth(); diff --git a/apps/files/download.php b/apps/files/download.php index e98cf2ecd31..2b5d4e2d876 100755 --- a/apps/files/download.php +++ b/apps/files/download.php @@ -31,7 +31,7 @@ $filename = $_GET["file"]; if(!OC_Filesystem::file_exists($filename)){ header("HTTP/1.0 404 Not Found"); - $tmpl = new OC_Template( '', '404', 'guest' ); + $tmpl = new OCP\Template( '', '404', 'guest' ); $tmpl->assign('file',$filename); $tmpl->printPage(); exit; diff --git a/apps/files/index.php b/apps/files/index.php index e2a0eb80a03..0c439e4ae1a 100755 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -72,11 +72,11 @@ foreach( explode( "/", $dir ) as $i ){ } // make breadcrumb und filelist markup -$list = new OC_Template( "files", "part.list", "" ); +$list = new OCP\Template( "files", "part.list", "" ); $list->assign( "files", $files ); $list->assign( "baseURL", OCP\Util::linkTo("files", "index.php")."?dir="); $list->assign( "downloadURL", OCP\Util::linkTo("files", "download.php")."?file="); -$breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" ); +$breadcrumbNav = new OCP\Template( "files", "part.breadcrumb", "" ); $breadcrumbNav->assign( "breadcrumb", $breadcrumb ); $breadcrumbNav->assign( "baseURL", OCP\Util::linkTo("files", "index.php")."?dir="); @@ -88,7 +88,7 @@ $freeSpace=OC_Filesystem::free_space('/'); $freeSpace=max($freeSpace,0); $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); -$tmpl = new OC_Template( "files", "index", "user" ); +$tmpl = new OCP\Template( "files", "index", "user" ); $tmpl->assign( "fileList", $list->fetchPage() ); $tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() ); $tmpl->assign( 'dir', $dir); diff --git a/apps/files/settings.php b/apps/files/settings.php index cfadc54573d..e5a66239ebd 100755 --- a/apps/files/settings.php +++ b/apps/files/settings.php @@ -52,7 +52,7 @@ foreach( explode( "/", $dir ) as $i ){ } // return template -$tmpl = new OC_Template( "files", "index", "user" ); +$tmpl = new OCP\Template( "files", "index", "user" ); $tmpl->assign( 'files', $files ); $tmpl->assign( "breadcrumb", $breadcrumb ); $tmpl->printPage(); diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 25193648387..72e45d53275 100755 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -6,9 +6,9 @@ <div id='new' class='button'> <a><?php echo $l->t('New');?></a> <ul class="popup popupTop"> - <li style="background-image:url('<?php echo mimetype_icon('text/plain') ?>')" data-type='file'><p><?php echo $l->t('Text file');?></p></li> - <li style="background-image:url('<?php echo mimetype_icon('dir') ?>')" data-type='folder'><p><?php echo $l->t('Folder');?></p></li> - <li style="background-image:url('<?php echo image_path('core','actions/public.png') ?>')" data-type='web'><p><?php echo $l->t('From url');?></p></li> + <li style="background-image:url('<?php echo OCP\mimetype_icon('text/plain') ?>')" data-type='file'><p><?php echo $l->t('Text file');?></p></li> + <li style="background-image:url('<?php echo OCP\mimetype_icon('dir') ?>')" data-type='folder'><p><?php echo $l->t('Folder');?></p></li> + <li style="background-image:url('<?php echo OCP\image_path('core','actions/public.png') ?>')" data-type='web'><p><?php echo $l->t('From url');?></p></li> </ul> </div> <div class="file_upload_wrapper svg"> @@ -16,7 +16,7 @@ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_['uploadMaxFilesize'] ?>" id="max_upload"> <input type="hidden" class="max_human_file_size" value="(max <?php echo $_['uploadMaxHumanFilesize']; ?>)"> <input type="hidden" name="dir" value="<?php echo htmlentities($_['dir']) ?>" id="dir"> - <button class="file_upload_filename"> <img class='svg action' alt="Upload" src="<?php echo image_path("core", "actions/upload.svg"); ?>" /></button> + <button class="file_upload_filename"> <img class='svg action' alt="Upload" src="<?php echo OCP\image_path("core", "actions/upload.svg"); ?>" /></button> <input class="file_upload_start" type="file" name='files[]'/> <a href="#" class="file_upload_button_wrapper" onclick="return false;" title="<?php echo $l->t('Upload'); echo ' max. '.$_['uploadMaxHumanFilesize'] ?>"></a> <iframe name="file_upload_target_1" class='file_upload_target' src=""></iframe> @@ -46,14 +46,14 @@ <?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" id="select_all" /><?php } ?> <span class='name'><?php echo $l->t( 'Name' ); ?></span> <span class='selectedActions'> - <a href="" class="share"><img class='svg' alt="Share" src="<?php echo image_path("core", "actions/share.svg"); ?>" /> <?php echo $l->t('Share')?></a> + <a href="" class="share"><img class='svg' alt="Share" src="<?php echo OCP\image_path("core", "actions/share.svg"); ?>" /> <?php echo $l->t('Share')?></a> <?php if($_['allowZipDownload']) : ?> - <a href="" class="download"><img class='svg' alt="Download" src="<?php echo image_path("core", "actions/download.svg"); ?>" /> <?php echo $l->t('Download')?></a> + <a href="" class="download"><img class='svg' alt="Download" src="<?php echo OCP\image_path("core", "actions/download.svg"); ?>" /> <?php echo $l->t('Download')?></a> <?php endif; ?> </span> </th> <th id="headerSize"><?php echo $l->t( 'Size' ); ?></th> - <th id="headerDate"><span id="modified"><?php echo $l->t( 'Modified' ); ?></span><span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete all')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo image_path("core", "actions/delete.svg"); ?>" /></a></span></th> + <th id="headerDate"><span id="modified"><?php echo $l->t( 'Modified' ); ?></span><span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete all')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span></th> </tr> </thead> <tbody id="fileList" data-readonly="<?php echo $_['readonly'];?>"> diff --git a/apps/files/templates/part.breadcrumb.php b/apps/files/templates/part.breadcrumb.php index 16da6bb97b4..41d2c5c8e76 100644..100755 --- a/apps/files/templates/part.breadcrumb.php +++ b/apps/files/templates/part.breadcrumb.php @@ -1,6 +1,6 @@ <?php for($i=0; $i<count($_["breadcrumb"]); $i++): $crumb = $_["breadcrumb"][$i]; ?> - <div class="crumb <?php if($i == count($_["breadcrumb"])-1) echo 'last';?> svg" data-dir='<?php echo $crumb["dir"];?>' style='background-image:url("<?php echo image_path('core','breadcrumb.png');?>")'> + <div class="crumb <?php if($i == count($_["breadcrumb"])-1) echo 'last';?> svg" data-dir='<?php echo $crumb["dir"];?>' style='background-image:url("<?php echo OCP\image_path('core','breadcrumb.png');?>")'> <a href="<?php echo $_['baseURL'].$crumb["dir"]; ?>"><?php echo htmlentities($crumb["name"]); ?></a> </div> <?php endfor;?>
\ No newline at end of file diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index b2db4cbb8df..4506630c16d 100644..100755 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,9 +1,9 @@ <?php foreach($_['files'] as $file): $write = ($file['writable']) ? 'true' : 'false'; - $simple_file_size = simple_file_size($file['size']); + $simple_file_size = OCP\simple_file_size($file['size']); $simple_size_color = intval(200-$file['size']/(1024*1024)*2); // the bigger the file, the darker the shade of grey; megabytes*2 if($simple_size_color<0) $simple_size_color = 0; - $relative_modified_date = relative_modified_date($file['mtime']); + $relative_modified_date = OCP\relative_modified_date($file['mtime']); $relative_date_color = round((time()-$file['mtime'])/60/60/24*14); // the older the file, the brighter the shade of grey; days*14 if($relative_date_color>200) $relative_date_color = 200; $name = str_replace('+','%20',urlencode($file['name'])); @@ -11,7 +11,7 @@ $directory = str_replace('+','%20',urlencode($file['directory'])); $directory = str_replace('%2F','/', $directory); ?> <tr data-file="<?php echo $name;?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mimetype']?>" data-size='<?php echo $file['size'];?>' data-write='<?php echo $write;?>'> - <td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mimetype']); ?>)"> + <td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo OCP\mimetype_icon('dir'); else echo OCP\mimetype_icon($file['mimetype']); ?>)"> <?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" /><?php } ?> <a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$directory.'/'.$name; else echo $_['downloadURL'].$directory.'/'.$name; ?>" title=""> <span class="nametext"> @@ -27,7 +27,7 @@ <?php endif;?> </a> </td> - <td class="filesize" title="<?php echo human_file_size($file['size']); ?>" style="color:rgb(<?php echo $simple_size_color.','.$simple_size_color.','.$simple_size_color ?>)"><?php echo $simple_file_size; ?></td> + <td class="filesize" title="<?php echo OCP\human_file_size($file['size']); ?>" style="color:rgb(<?php echo $simple_size_color.','.$simple_size_color.','.$simple_size_color ?>)"><?php echo $simple_file_size; ?></td> <td class="date"><span class="modified" title="<?php echo $file['date']; ?>" style="color:rgb(<?php echo $relative_date_color.','.$relative_date_color.','.$relative_date_color ?>)"><?php echo $relative_modified_date; ?></span></td> </tr> <?php endforeach; ?> diff --git a/apps/files_encryption/settings.php b/apps/files_encryption/settings.php index aed9079529c..0a0d4d1abba 100755 --- a/apps/files_encryption/settings.php +++ b/apps/files_encryption/settings.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -$tmpl = new OC_Template( 'files_encryption', 'settings'); +$tmpl = new OCP\Template( 'files_encryption', 'settings'); $blackList=explode(',',OCP\Config::getAppValue('files_encryption','type_blacklist','jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg')); $enabled=(OCP\Config::getAppValue('files_encryption','enable_encryption','true')=='true'); $tmpl->assign('blacklist',$blackList); diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php index d9404f7e3b4..6eed0408238 100755 --- a/apps/files_sharing/ajax/getitem.php +++ b/apps/files_sharing/ajax/getitem.php @@ -1,36 +1,69 @@ <?php -//$RUNTIME_NOAPPS = true; - +require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); OCP\JSON::checkAppEnabled('files_sharing'); -require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); +OCP\JSON::checkLoggedIn(); -$userDirectory = "/".OCP\USER::getUser()."/files"; -$source = $userDirectory.$_GET['source']; +$item = array(); +$userDirectory = '/'.OCP\USER::getUser().'/files'; +$source = $userDirectory.$_GET['item']; $path = $source; -$users = array(); -if ($users = OC_Share::getMySharedItem($source)) { - for ($i = 0; $i < count($users); $i++) { - if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { - $users[$i]['token'] = OC_Share::getTokenFromSource($source); - } - } -} -$source = dirname($source); -while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) { - if ($values = OC_Share::getMySharedItem($source)) { - $values = array_values($values); - $parentUsers = array(); - for ($i = 0; $i < count($values); $i++) { - if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { - $values[$i]['token'] = OC_Share::getTokenFromSource($source)."&path=".substr($path, strlen($source)); +// Search for item and shared parent folders +while ($path != $userDirectory) { + if ($rows = OC_Share::getMySharedItem($path)) { + for ($i = 0; $i < count($rows); $i++) { + $uid_shared_with = $rows[$i]['uid_shared_with']; + if ($uid_shared_with == OC_Share::PUBLICLINK && !isset($item['privateLink'])) { + $token = OC_Share::getTokenFromSource($path); + if ($path == $source) { + $item['privateLink'] = $token; + } else { + // If in parent folder, include a path parameter to get direct access to file + $item['privateLink'] = $token.'&path='.substr($source, strlen($path)); + } + } else { + // Check if uid_shared_with is a group + if (($pos = strpos($uid_shared_with, '@')) !== false) { + $gid = substr($uid_shared_with, $pos + 1); + // Include users in the group so the users can be removed from the list of people to share with + if ($path == $source) { + $group = array(array('gid' => $gid, 'permissions' => $rows[$i]['permissions'], 'users' => OC_Group::usersInGroup($gid), 'parentFolder' => false)); + } else { + $group = array(array('gid' => $gid, 'permissions' => $rows[$i]['permissions'], 'users' => OC_Group::usersInGroup($gid), 'parentFolder' => basename($path))); + } + if (!isset($item['groups'])) { + $item['groups'] = $group; + } else if (is_array($item['groups'])) { + $gidExists = false; + $currentGroups = $item['groups']; + // Check if the group is already included + foreach ($currentGroups as $g) { + if ($g['gid'] == $gid) { + $gidExists = true; + } + } + if (!$gidExists) { + $item['groups'] = array_merge($item['groups'], $group); + } + } + } else { + if ($path == $source) { + $user = array(array('uid' => $uid_shared_with, 'permissions' => $rows[$i]['permissions'], 'parentFolder' => false)); + } else { + $user = array(array('uid' => $uid_shared_with, 'permissions' => $rows[$i]['permissions'], 'parentFolder' => basename($path))); + } + if (!isset($item['users'])) { + $item['users'] = $user; + } else if (is_array($item['users'])) { + $item['users'] = array_merge($item['users'], $user); + } + } } - $parentUsers[basename($source)."-".$i] = $values[$i]; } - $users = array_merge($users, $parentUsers); } - $source = dirname($source); -} -if (!empty($users)) { - OCP\JSON::encodedPrint($users); + $path = dirname($path); } + +OCP\JSON::success(array('data' => $item)); + +?> diff --git a/apps/files_sharing/ajax/getstatuses.php b/apps/files_sharing/ajax/getstatuses.php new file mode 100644 index 00000000000..c1892e7e2a2 --- /dev/null +++ b/apps/files_sharing/ajax/getstatuses.php @@ -0,0 +1,25 @@ +<?php +require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); + +OCP\JSON::checkAppEnabled('files_sharing'); +OCP\JSON::checkLoggedIn(); + +$items = array(); +$userDirectory = '/'.OCP\USER::getUser().'/files'; +$dirLength = strlen($userDirectory); +if ($rows = OC_Share::getMySharedItems()) { + for ($i = 0; $i < count($rows); $i++) { + $source = $rows[$i]['source']; + // Strip out user directory + $item = substr($source, $dirLength); + if ($rows[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { + $items[$item] = true; + } else { + $items[$item] = false; + } + } +} + +OCP\JSON::success(array('data' => $items)); + +?>
\ No newline at end of file diff --git a/apps/files_sharing/ajax/setpermissions.php b/apps/files_sharing/ajax/setpermissions.php index 73f59d73db2..2f4c5da9788 100755 --- a/apps/files_sharing/ajax/setpermissions.php +++ b/apps/files_sharing/ajax/setpermissions.php @@ -1,13 +1,14 @@ <?php -//$RUNTIME_NOAPPS = true; +require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); - OCP\JSON::checkAppEnabled('files_sharing'); -require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); +OCP\JSON::checkLoggedIn(); -$source = "/".OCP\USER::getUser()."/files".$_GET['source']; -$uid_shared_with = $_GET['uid_shared_with']; -$permissions = $_GET['permissions']; +$source = '/'.OCP\USER::getUser().'/files'.$_POST['source']; +$uid_shared_with = $_POST['uid_shared_with']; +$permissions = $_POST['permissions']; OC_Share::setPermissions($source, $uid_shared_with, $permissions); +OCP\JSON::success(); + ?> diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php index 4863170f57c..4478144e92f 100755 --- a/apps/files_sharing/ajax/share.php +++ b/apps/files_sharing/ajax/share.php @@ -1,31 +1,33 @@ <?php -//$RUNTIME_NOAPPS = true; +require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); - OCP\JSON::checkAppEnabled('files_sharing'); -require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); +OCP\JSON::checkLoggedIn(); -$userDirectory = "/".OCP\USER::getUser()."/files"; -$sources = explode(";", $_POST['sources']); +$userDirectory = '/'.OCP\USER::getUser().'/files'; +$sources = explode(';', $_POST['sources']); $uid_shared_with = $_POST['uid_shared_with']; $permissions = $_POST['permissions']; foreach ($sources as $source) { - // Make sure file exists and can be shared - if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) { - $source = $userDirectory.$source; - // If the file doesn't exist, it may be shared with the current user - } else if (!$source = OC_Share::getSource($userDirectory.$source)) { - OCP\Util::writeLog('files_sharing',"Shared file doesn't exists :".$source,OCP\Util::ERROR); - echo "false"; - } - try { - $shared = new OC_Share($source, $uid_shared_with, $permissions); - if ($uid_shared_with == OC_Share::PUBLICLINK) { - echo $shared->getToken(); + $path = ltrim($source, '/'); + $source = $userDirectory.$source; + // Check if the file exists or if the file is being reshared + if ($source && (OC_FILESYSTEM::file_exists($path) && OC_FILESYSTEM::is_readable($path) || OC_Share::getSource($source))) { + try { + $shared = new OC_Share($source, $uid_shared_with, $permissions); + // If this is a private link, return the token + if ($uid_shared_with == OC_Share::PUBLICLINK) { + OCP\JSON::success(array('data' => $shared->getToken())); + } else { + OCP\JSON::success(); + } + } catch (Exception $exception) { + OCP\Util::writeLog('files_sharing', 'Unexpected Error : '.$exception->getMessage(), OCP\Util::ERROR); + OCP\JSON::error(array('data' => array('message' => $exception->getMessage()))); } - } catch (Exception $exception) { - OCP\Util::writeLog('files_sharing',"Unexpected Error : ".$exception->getMessage(),OCP\Util::ERROR); - echo "false"; + } else { + OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :'.$source, OCP\Util::ERROR); + OCP\JSON::error(array('data' => array('message' => 'File does not exist or is not readable'))); } } diff --git a/apps/files_sharing/ajax/unshare.php b/apps/files_sharing/ajax/unshare.php index 5056c59a3d4..9088bf42663 100755 --- a/apps/files_sharing/ajax/unshare.php +++ b/apps/files_sharing/ajax/unshare.php @@ -1,12 +1,13 @@ <?php -//$RUNTIME_NOAPPS = true; +require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); - OCP\JSON::checkAppEnabled('files_sharing'); -require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php'); +OCP\JSON::checkLoggedIn(); -$source = "/".OCP\USER::getUser()."/files".$_GET['source']; -$uid_shared_with = $_GET['uid_shared_with']; +$source = '/'.OCP\USER::getUser().'/files'.$_POST['source']; +$uid_shared_with = $_POST['uid_shared_with']; OC_Share::unshare($source, $uid_shared_with); +OCP\JSON::success(); + ?> diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php index 73b5f126984..99cc81bce04 100755 --- a/apps/files_sharing/ajax/userautocomplete.php +++ b/apps/files_sharing/ajax/userautocomplete.php @@ -1,7 +1,4 @@ <?php -//$RUNTIME_NOAPPS = true; - - OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('files_sharing'); @@ -14,12 +11,17 @@ $users[] = "<optgroup label='Users'>"; $groups[] = "<optgroup label='Groups'>"; foreach ($userGroups as $group) { $groupUsers = OC_Group::usersInGroup($group); + $userCount = 0; foreach ($groupUsers as $user) { if ($user != $self) { $users[] = "<option value='".$user."'>".$user."</option>"; + $userCount++; } } - $groups[] = "<option value='".$group."'>".$group."</option>"; + // Don't include the group if only the current user is a member of it + if ($userCount > 0) { + $groups[] = "<option value='".$group."(group)'>".$group." (group) </option>"; + } } $users[] = "</optgroup>"; $groups[] = "</optgroup>"; diff --git a/apps/files_sharing/css/sharing.css b/apps/files_sharing/css/sharing.css index 5acd9af589a..c4b4540e9d1 100644 --- a/apps/files_sharing/css/sharing.css +++ b/apps/files_sharing/css/sharing.css @@ -6,8 +6,9 @@ -moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; } -#shared_list { padding:0.5em; list-style-type: none; } -#public { border-top:1px solid #ddd; padding-top:0.5em; } +#sharedWithList { padding:0.5em; list-style-type: none; } +#privateLink { border-top:1px solid #ddd; padding-top:0.5em; } a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; opacity:.5; } a.unshare:hover { opacity:1; } #share_with { width: 16em; } +#privateLink label, .edit { font-weight:normal; } diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php index de3bc5f46dc..2b2c9dd07fd 100755 --- a/apps/files_sharing/get.php +++ b/apps/files_sharing/get.php @@ -17,7 +17,7 @@ if ($source !== false) { $source .= $subPath; if (!OC_Filesystem::file_exists($source)) { header("HTTP/1.0 404 Not Found"); - $tmpl = new OC_Template("", "404", "guest"); + $tmpl = new OCP\Template("", "404", "guest"); $tmpl->assign("file", $subPath); $tmpl->printPage(); exit; @@ -49,15 +49,15 @@ if ($source !== false) { } // Load the files we need OCP\Util::addStyle("files", "files"); - $breadcrumbNav = new OC_Template("files", "part.breadcrumb", ""); + $breadcrumbNav = new OCP\Template("files", "part.breadcrumb", ""); $breadcrumbNav->assign("breadcrumb", $breadcrumb); $breadcrumbNav->assign("baseURL", OCP\Util::linkTo("files_sharing", "get.php")."?token=".$token."&path="); - $list = new OC_Template("files", "part.list", ""); + $list = new OCP\Template("files", "part.list", ""); $list->assign("files", $files); $list->assign("baseURL", OCP\Util::linkTo("files_sharing", "get.php")."?token=".$token."&path="); $list->assign("downloadURL", OCP\Util::linkTo("files_sharing", "get.php")."?token=".$token."&path="); $list->assign("readonly", true); - $tmpl = new OC_Template("files", "index", "user"); + $tmpl = new OCP\Template("files", "index", "user"); $tmpl->assign("fileList", $list->fetchPage()); $tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage()); $tmpl->assign("readonly", true); @@ -78,7 +78,7 @@ if ($source !== false) { } } else { header("HTTP/1.0 404 Not Found"); - $tmpl = new OC_Template("", "404", "guest"); + $tmpl = new OCP\Template("", "404", "guest"); $tmpl->printPage(); die(); } diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 4125fd14d25..7bfaa1f0c69 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -1,100 +1,276 @@ +OC.Share={ + icons:[], + itemUsers:[], + itemGroups:[], + itemPrivateLink:false, + usersAndGroups:[], + loadIcons:function() { + // Cache all icons for shared files + $.getJSON(OC.filePath('files_sharing', 'ajax', 'getstatuses.php'), function(result) { + if (result && result.status === 'success') { + $.each(result.data, function(item, hasPrivateLink) { + if (hasPrivateLink) { + OC.Share.icons[item] = OC.imagePath('core', 'actions/public'); + } else { + OC.Share.icons[item] = OC.imagePath('core', 'actions/shared'); + } + }); + } + }); + }, + loadItem:function(item) { + $.ajax({type: 'GET', url: OC.filePath('files_sharing', 'ajax', 'getitem.php'), data: { item: item }, async: false, success: function(result) { + if (result && result.status === 'success') { + var item = result.data; + OC.Share.itemUsers = item.users; + OC.Share.itemGroups = item.groups; + OC.Share.itemPrivateLink = item.privateLink; + } + }}); + }, + share:function(source, uid_shared_with, permissions, callback) { + $.post(OC.filePath('files_sharing', 'ajax', 'share.php'), { sources: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) { + if (result && result.status === 'success') { + if (callback) { + callback(result.data); + } + } else { + OC.dialogs.alert(result.data.message, 'Error while sharing'); + } + }); + }, + unshare:function(source, uid_shared_with, callback) { + $.post(OC.filePath('files_sharing', 'ajax', 'unshare.php'), { source: source, uid_shared_with: uid_shared_with }, function(result) { + if (result && result.status === 'success') { + if (callback) { + callback(); + } + } else { + OC.dialogs.alert('Error', 'Error while unsharing'); + } + }); + }, + changePermissions:function(source, uid_shared_with, permissions) { + $.post(OC.filePath('files_sharing','ajax','setpermissions.php'), { source: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) { + if (!result || result.status !== 'success') { + OC.dialogs.alert('Error', 'Error while changing permissions'); + } + }); + }, + showDropDown:function(item, appendTo) { + OC.Share.loadItem(item); + var html = '<div id="dropdown" class="drop" data-item="'+item+'">'; + html += '<select data-placeholder="User or Group" id="share_with" class="chzen-select">'; + html += '<option value=""></option>'; + html += '</select>'; + html += '<div id="sharedWithList">'; + html += '<ul id="userList"></ul>'; + html += '<div id="groups" style="display:none;">'; + html += '<br />'; + html += 'Groups: '; + html += '<ul id="groupList"></ul>'; + html += '</div>'; + html += '</div>'; + html += '<div id="privateLink">'; + html += '<input type="checkbox" name="privateLinkCheckbox" id="privateLinkCheckbox" value="1" /><label for="privateLinkCheckbox">Share with private link</label>'; + html += '<br />'; + html += '<input id="privateLinkText" style="display:none; width:90%;" />'; + html += '<input id="email" style="display:none; width:65%;" value="" placeholder="Email link to person" />'; + html += '<input id="emailButton" style="display:none;" type="submit" value="Send" />'; + html += '</div>'; + $(html).appendTo(appendTo); + if (OC.Share.usersAndGroups.length < 1) { + $.getJSON(OC.filePath('files_sharing', 'ajax', 'userautocomplete.php'), function(users) { + if (users) { + OC.Share.usersAndGroups = users; + $.each(users, function(index, user) { + $(user).appendTo('#share_with'); + }); + $('#share_with').trigger('liszt:updated'); + } + }); + } else { + $.each(OC.Share.usersAndGroups, function(index, user) { + $(user).appendTo('#share_with'); + }); + $('#share_with').trigger('liszt:updated'); + } + if (OC.Share.itemUsers) { + $.each(OC.Share.itemUsers, function(index, user) { + if (user.parentFolder) { + OC.Share.addSharedWith(user.uid, user.permissions, false, user.parentFolder); + } else { + OC.Share.addSharedWith(user.uid, user.permissions, false, false); + } + }); + } + if (OC.Share.itemGroups) { + $.each(OC.Share.itemGroups, function(index, group) { + if (group.parentFolder) { + OC.Share.addSharedWith(group.gid, group.permissions, group.users, group.parentFolder); + } else { + OC.Share.addSharedWith(group.gid, group.permissions, group.users, false); + } + }); + } + if (OC.Share.itemPrivateLink) { + OC.Share.showPrivateLink(item, OC.Share.itemPrivateLink); + } + $('#dropdown').show('blind'); + $('#share_with').chosen(); + }, + hideDropDown:function(callback) { + $('#dropdown').hide('blind', function() { + $('#dropdown').remove(); + if (callback) { + callback.call(); + } + }); + }, + addSharedWith:function(uid_shared_with, permissions, isGroup, parentFolder) { + if (parentFolder) { + var sharedWith = '<li>Parent folder '+parentFolder+' shared with '+uid_shared_with+'</li>'; + } else { + var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"'); + var style = ((permissions == 0) ? 'style="display:none;"' : ''); + var sharedWith = '<li data-uid_shared_with="'+uid_shared_with+'">'; + sharedWith += '<a href="" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>'; + sharedWith += uid_shared_with; + sharedWith += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" '+checked+' />'; + sharedWith += '<label class="edit" for="'+uid_shared_with+'" '+style+'>can edit</label>'; + sharedWith += '</li>'; + } + if (isGroup) { + // Groups are added to a different list + $('#groups').show(); + $(sharedWith).appendTo('#groupList'); + // Remove group from select form + $('#share_with option[value="'+uid_shared_with+'(group)"]').remove(); + $('#share_with').trigger('liszt:updated'); + // Remove users in group from select form + $.each(isGroup, function(index, user) { + $('#share_with option[value="'+user+'"]').remove(); + $('#share_with').trigger('liszt:updated'); + }); + } else { + $(sharedWith).appendTo('#userList'); + // Remove user from select form + $('#share_with option[value="'+uid_shared_with+'"]').remove(); + $('#share_with').trigger('liszt:updated'); + } + + }, + removeSharedWith:function(uid_shared_with) { + var option; + if ($('#userList li[data-uid_shared_with="'+uid_shared_with+'"]').length > 0) { + $('#userList li[data-uid_shared_with="'+uid_shared_with+'"]').remove(); + option = '<option value="'+uid_shared_with+'">'+uid_shared_with+'</option>'; + } else if ($('#groupList li[data-uid_shared_with="'+uid_shared_with+'"]').length > 0) { + $('#groupList li[data-uid_shared_with="'+uid_shared_with+'"]').remove(); + if ($('#groupList li').length < 1) { + $('#groups').hide(); + } + option = '<option value="'+uid_shared_with+'(group)">'+uid_shared_with+' (group)</option>'; + } + $(option).appendTo('#share_with'); + $('#share_with').trigger('liszt:updated'); + }, + showPrivateLink:function(item, token) { + $('#privateLinkCheckbox').attr('checked', true); + var link = parent.location.protocol+'//'+location.host+OC.linkTo('files_sharing','get.php')+'?token='+token; + if (token.indexOf('&path=') == -1) { + link += '&file=' + item; + } else { + // Disable checkbox if inside a shared parent folder + $('#privateLinkCheckbox').attr('disabled', 'true'); + } + $('#privateLinkText').val(link); + $('#privateLinkText').show('blind', function() { + $('#privateLinkText').after('<br id="emailBreak" />'); + $('#email').show(); + $('#emailButton').show(); + }); + }, + hidePrivateLink:function() { + $('#privateLinkText').hide('blind'); + $('#emailBreak').remove(); + $('#email').hide(); + $('#emailButton').hide(); + }, + emailPrivateLink:function() { + $('#email').css('font-weight', 'bold'); + $('#email').animate({ fontWeight: 'normal' }, 2000, function() { + $(this).val(''); + }).val('Email sent'); + $.post(OC.filePath('files_sharing', 'ajax', 'email.php'), 'toaddress='+$('#email').val()+'&link='+$('#link').val()); + }, + dirname:function(path) { + return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); + } +} + $(document).ready(function() { - var shared_status = {}; + OC.Share.loadIcons(); + if (typeof FileActions !== 'undefined') { FileActions.register('all', 'Share', function(filename) { - if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback - var icon; - if (typeof filename == 'undefined') { - return false; - } - var file = $('#dir').val()+'/'+filename; - if(shared_status[file]) - return shared_status[file].icon; - $.ajax({ - type: 'GET', - url: OC.linkTo('files_sharing', 'ajax/getitem.php'), - dataType: 'json', - data: {source: file}, - async: false, - success: function(users) { - if (users) { - icon = OC.imagePath('core', 'actions/shared'); - $.each(users, function(index, row) { - if (row.uid_shared_with == 'public') { - icon = OC.imagePath('core', 'actions/public'); - } - }); - } else { - icon = OC.imagePath('core', 'actions/share'); + // Return the correct sharing icon + if (scanFiles.scanning) { return; } // workaround to prevent additional http request block scanning feedback + var item = $('#dir').val() + '/' + filename; + // Check if icon is in cache + if (OC.Share.icons[item]) { + return OC.Share.icons[item]; + } else { + var last = ''; + var path = OC.Share.dirname(item); + // Search for possible parent folders that are shared + while (path != last) { + if (OC.Share.icons[path]) { + OC.Share.icons[item] = OC.Share.icons[path]; + return OC.Share.icons[item]; } - shared_status[file]= { timestamp: new Date().getTime(), icon: icon }; + last = path; + path = OC.Share.dirname(path); } - }); - return icon; + OC.Share.icons[item] = OC.imagePath('core', 'actions/share'); + return OC.Share.icons[item]; + } }, function(filename) { + var file = $('#dir').val() + '/' + filename; + var appendTo = $('tr').filterAttr('data-file',filename).find('td.filename'); + // Check if drop down is already visible for a different file if (($('#dropdown').length > 0)) { - $('#dropdown').hide('blind', function() { - var dropdownFile = $('#dropdown').data('file') - var file = $('#dir').val()+'/'+filename; - $('#dropdown').remove(); - $('tr').removeClass('mouseOver'); - if (dropdownFile != file) { - createDropdown(filename, file); - } - }); + if (file != $('#dropdown').data('item')) { + OC.Share.hideDropDown(function () { + $('tr').removeClass('mouseOver'); + $('tr').filterAttr('data-file',filename).addClass('mouseOver'); + OC.Share.showDropDown(file, appendTo); + }); + } } else { - createDropdown(filename, $('#dir').val()+'/'+filename); + $('tr').filterAttr('data-file',filename).addClass('mouseOver'); + OC.Share.showDropDown(file, appendTo); } }); }; - - $('.share').click(function(event) { - event.preventDefault(); - event.stopPropagation(); - var filenames = getSelectedFiles('name'); - var length = filenames.length; - var files = ''; - for (var i = 0; i < length; i++) { - files += $('#dir').val()+'/'+filenames[i]+';'; - } - createDropdown(false, files); - }); $(this).click(function(event) { if (!($(event.target).hasClass('drop')) && $(event.target).parents().index($('#dropdown')) == -1) { if ($('#dropdown').is(':visible')) { - delete shared_status[$('#dropdown').data('file')]; //Remove File from icon cache - $('#dropdown').hide('blind', function() { - $('#dropdown').remove(); + OC.Share.hideDropDown(function() { $('tr').removeClass('mouseOver'); }); } } }); - - $('#share_with').live('change', function() { - var source = $('#dropdown').data('file'); - var uid_shared_with = $(this).val(); - var permissions = 0; - var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions); - $.ajax({ - type: 'POST', - url: OC.linkTo('files_sharing','ajax/share.php'), - cache: false, - data: data, - success: function(result) { - if (result !== 'false') { - addUser(uid_shared_with, permissions, false); - } - } - }); - }); - - $('#shared_list > li').live('mouseenter', function(event) { + + $('#sharedWithList li').live('mouseenter', function(event) { + // Show permissions and unshare button $(':hidden', this).show(); }); - $('#shared_list > li').live('mouseleave', function(event) { + $('#sharedWithList li').live('mouseleave', function(event) { + // Hide permissions and unshare button $('a', this).hide(); if (!$('input:[type=checkbox]', this).is(':checked')) { $('input:[type=checkbox]', this).hide(); @@ -102,161 +278,85 @@ $(document).ready(function() { } }); - $('.permissions').live('change', function() { - var permissions = (this.checked) ? 1 : 0; - var source = $('#dropdown').data('file'); - var uid_shared_with = $(this).parent().data('uid_shared_with'); - var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions); - $.ajax({ - type: 'GET', - url: OC.linkTo('files_sharing','ajax/setpermissions.php'), - cache: false, - data: data + $('#share_with').live('change', function() { + var item = $('#dropdown').data('item'); + var uid_shared_with = $(this).val(); + var pos = uid_shared_with.indexOf('(group)'); + var isGroup = false; + if (pos != -1) { + // Remove '(group)' from uid_shared_with + uid_shared_with = uid_shared_with.substr(0, pos); + isGroup = true; + } + OC.Share.share(item, uid_shared_with, 0, function() { + if (isGroup) { + // Reload item because we don't know which users are in the group + OC.Share.loadItem(item); + var users; + $.each(OC.Share.itemGroups, function(index, group) { + if (group.gid == uid_shared_with) { + users = group.users; + } + }); + OC.Share.addSharedWith(uid_shared_with, 0, users, false); + } else { + OC.Share.addSharedWith(uid_shared_with, 0, false, false); + } + // Change icon + if (!OC.Share.itemPrivateLink) { + OC.Share.icons[item] = OC.imagePath('core', 'actions/shared'); + } }); }); - - $('.unshare').live('click', function(event) { - event.preventDefault(); - var user = $(this).parent(); - var source = $('#dropdown').data('file'); - var uid_shared_with = user.data('uid_shared_with'); - var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with); - $.ajax({ - type: 'GET', - url: OC.linkTo('files_sharing','ajax/unshare.php'), - cache: false, - data: data, - success: function() { - var option = '<option value="'+uid_shared_with+'">'+uid_shared_with+'</option>'; - $(user).remove(); - $(option).appendTo('#share_with'); - $('#share_with').trigger('liszt:updated'); + + $('.unshare').live('click', function() { + var item = $('#dropdown').data('item'); + var uid_shared_with = $(this).parent().data('uid_shared_with'); + OC.Share.unshare(item, uid_shared_with, function() { + OC.Share.removeSharedWith(uid_shared_with); + // Reload item to update cached users and groups for the icon check + OC.Share.loadItem(item); + // Change icon + if (!OC.Share.itemPrivateLink && !OC.Share.itemUsers && !OC.Share.itemGroups) { + OC.Share.icons[item] = OC.imagePath('core', 'actions/share'); } }); }); - $('#makelink').live('change', function() { + $('.permissions').live('change', function() { + var permissions = (this.checked) ? 1 : 0; + OC.Share.changePermissions($('#dropdown').data('item'), $(this).parent().data('uid_shared_with'), permissions); + }); + + $('#privateLinkCheckbox').live('change', function() { + var item = $('#dropdown').data('item'); if (this.checked) { - var source = $('#dropdown').data('file'); - var uid_shared_with = 'public'; - var permissions = 0; - var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions); - $.ajax({ - type: 'POST', - url: OC.linkTo('files_sharing','ajax/share.php'), - cache: false, - data: data, - success: function(token) { - if (token) { - showPublicLink(token, source.substr(source.lastIndexOf('/'))); - } - } + // Create a private link + OC.Share.share(item, 'public', 0, function(token) { + OC.Share.showPrivateLink(item, token); + // Change icon + OC.Share.icons[item] = OC.imagePath('core', 'actions/public'); }); } else { - var source = $('#dropdown').data('file'); - var uid_shared_with = 'public'; - var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with); - $.ajax({ - type: 'GET', - url: OC.linkTo('files_sharing','ajax/unshare.php'), - cache: false, - data: data, - success: function(){ - $('#link').hide('blind'); - $('#emailBreak').remove(); - $('#email').hide('blind'); - $('#emailButton').hide('blind'); + // Delete private link + OC.Share.unshare(item, 'public', function() { + OC.Share.hidePrivateLink(); + // Change icon + if (OC.Share.itemUsers || OC.Share.itemGroups) { + OC.Share.icons[item] = OC.imagePath('core', 'actions/shared'); + } else { + OC.Share.icons[item] = OC.imagePath('core', 'actions/share'); } }); } }); - $('#link').live('click', function() { + $('#privateLinkText').live('click', function() { $(this).focus(); $(this).select(); }); $('#emailButton').live('click', function() { - $('#email').css('font-weight', 'bold'); - $('#email').animate({ fontWeight: 'normal' }, 2000, function() { - $(this).val(''); - }).val('Email sent'); - $.post(OC.filePath('files_sharing','ajax','email.php'), 'toaddress='+$('#email').val()+'&link='+$('#link').val()); + OC.Share.emailPrivateLink(); }); -}); - -function createDropdown(filename, files) { - var html = '<div id="dropdown" class="drop" data-file="'+files+'">'; - html += '<div id="private">'; - html += '<select data-placeholder="User or Group" id="share_with" class="chzen-select">'; - html += '<option value=""></option>'; - html += '</select>'; - html += '<ul id="shared_list"></ul>'; - html += '</div>'; - html += '<div id="public">'; - html += '<input type="checkbox" name="makelink" id="makelink" value="1" /><label for="makelink">Share with private link</label>'; - //html += '<input type="checkbox" name="public_link_write" id="public_link_write" value="1" /><label for="public_link_write">allow upload</label>'; - html += '<br />'; - html += '<input id="link" style="display:none; width:90%;" />'; - html += '<input id="email" style="display:none; width:65%;" value="" placeholder="Email link to person" />'; - html += '<input id="emailButton" style="display:none;" type="submit" value="Send" />'; - html += '</div>'; - if (filename) { - $('tr').filterAttr('data-file',filename).addClass('mouseOver'); - $(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename')); - } else { - $(html).appendTo($('thead .share')); - } - $.getJSON(OC.linkTo('files_sharing', 'ajax/userautocomplete.php'), function(users) { - if (users) { - $.each(users, function(index, row) { - $(row).appendTo('#share_with'); - }); - $('#share_with').trigger('liszt:updated'); - } - }); - $.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) { - if (users) { - $.each(users, function(index, row) { - if (row.uid_shared_with == 'public') { - showPublicLink(row.token, '/'+filename); - } else if (isNaN(index)) { - addUser(row.uid_shared_with, row.permissions, index.substr(0, index.lastIndexOf('-'))); - } else { - addUser(row.uid_shared_with, row.permissions, false); - } - }); - } - }); - $('#dropdown').show('blind'); - $('#share_with').chosen(); -} - -function addUser(uid_shared_with, permissions, parentFolder) { - if (parentFolder) { - var user = '<li>Parent folder '+parentFolder+' shared with '+uid_shared_with+'</li>'; - } else { - var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"'); - var style = ((permissions == 0) ? 'style="display:none;"' : ''); - var user = '<li data-uid_shared_with="'+uid_shared_with+'">'; - user += '<a href="" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>'; - user += uid_shared_with; - user += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" '+checked+' />'; - user += '<label for="'+uid_shared_with+'" '+style+'>can edit</label>'; - user += '</li>'; - } - $('#share_with option[value="'+uid_shared_with+'"]').remove(); - $('#share_with').trigger('liszt:updated'); - $(user).appendTo('#shared_list'); -} - -function showPublicLink(token, file) { - $('#makelink').attr('checked', true); - $('#link').data('token', token); - $('#link').val(parent.location.protocol+'//'+location.host+OC.linkTo('files_sharing','get.php')+'?token='+token+'&f='+file); - $('#link').show('blind', function() { - $('#link').after('<br id="emailBreak" />'); - $('#email').show('blind'); - $('#emailButton').show('blind'); - }); -} +});
\ No newline at end of file diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index 71cca309776..c2340bdc181 100755 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -69,7 +69,7 @@ class OC_Share { } foreach ($uid_shared_with as $uid) { // Check if this item is already shared with the user - $checkSource = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid)); + $checkSource = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid, false)); $resultCheckSource = $checkSource->execute(array($source))->fetchAll(); // TODO Check if the source is inside a folder if (count($resultCheckSource) > 0 && !isset($gid)) { @@ -98,15 +98,8 @@ class OC_Share { $uid = $uid."@".$gid; } $query->execute(array($uid_owner, $uid, $source, $target, $permissions)); - // Add file to filesystem cache - $userDirectory = "/".OCP\USER::getUser()."/files"; - $data = OC_Filecache::get(substr($source, strlen($userDirectory))); - $parentQuery = OCP\DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?'); - $parentResult = $parentQuery->execute(array($sharedFolder))->fetchRow(); - $parent = $parentResult['id']; - $is_writeable = $permissions & OC_Share::WRITE; - $cacheQuery = OCP\DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)'); - $cacheQuery->execute(array($parent, basename($target), $target, $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], dirname($data['mimetype']), $uid, $is_writeable)); + // Update mtime of shared folder to invoke a file cache rescan + OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder); } } } @@ -125,7 +118,7 @@ class OC_Share { * @param $uid (Optional) The uid to get the user groups for, a gid to get the users in a group, or if not set the current user * @return An IN operator as a string */ - private static function getUsersAndGroups($uid = null) { + private static function getUsersAndGroups($uid = null, $includePrivateLinks = true) { $in = " IN("; if (isset($uid) && OC_Group::groupExists($uid)) { $users = OC_Group::usersInGroup($uid); @@ -152,7 +145,9 @@ class OC_Share { $in .= ", '".$uid."@".$group."'"; } } - $in .= ", '".self::PUBLICLINK."'"; + if ($includePrivateLinks) { + $in .= ", '".self::PUBLICLINK."'"; + } $in .= ")"; return $in; } @@ -381,6 +376,9 @@ class OC_Share { $source = self::cleanPath($source); $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with)); $query->execute(array(strlen($source), $source, OCP\USER::getUser())); + // Update mtime of shared folder to invoke a file cache rescan + $sharedFolder = '/'.$uid_shared_with.'/files/Shared'; + OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder); } /** diff --git a/apps/files_sharing/list.php b/apps/files_sharing/list.php index 2fe6bc88e63..2fd24840d36 100755 --- a/apps/files_sharing/list.php +++ b/apps/files_sharing/list.php @@ -30,7 +30,7 @@ OCP\App::setActiveNavigationEntry("files_sharing_list"); OCP\Util::addscript("files_sharing", "list"); -$tmpl = new OC_Template("files_sharing", "list", "user"); +$tmpl = new OCP\Template("files_sharing", "list", "user"); $tmpl->assign("shared_items", OC_Share::getMySharedItems()); $tmpl->printPage(); diff --git a/apps/files_sharing/settings.php b/apps/files_sharing/settings.php index a7bdf7b9195..7b63a26515a 100755 --- a/apps/files_sharing/settings.php +++ b/apps/files_sharing/settings.php @@ -2,7 +2,7 @@ OCP\User::checkAdminUser(); OCP\Util::addscript('files_sharing', 'settings'); -$tmpl = new OC_Template('files_sharing', 'settings'); +$tmpl = new OCP\Template('files_sharing', 'settings'); $tmpl->assign('allowResharing', OCP\Config::getAppValue('files_sharing', 'resharing', 'yes')); return $tmpl->fetchPage(); diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php index eb8886239d3..4306e416400 100755 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -24,7 +24,7 @@ require_once( '../../lib/base.php' ); OCP\User::checkLoggedIn( ); OCP\Util::addStyle('files_versions','versions'); -$tmpl = new OC_Template( 'files_versions', 'history', 'user' ); +$tmpl = new OCP\Template( 'files_versions', 'history', 'user' ); if ( isset( $_GET['path'] ) ) { diff --git a/apps/files_versions/settings.php b/apps/files_versions/settings.php index 59609de15b4..5f9e60fc589 100755 --- a/apps/files_versions/settings.php +++ b/apps/files_versions/settings.php @@ -4,7 +4,7 @@ OCP\User::checkAdminUser(); OCP\Util::addscript( 'files_versions', 'versions' ); -$tmpl = new OC_Template( 'files_versions', 'settings'); +$tmpl = new OCP\Template( 'files_versions', 'settings'); return $tmpl->fetchPage(); ?> diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml index 7dc85374b0b..5b5ee0f731b 100644 --- a/apps/gallery/appinfo/info.xml +++ b/apps/gallery/appinfo/info.xml @@ -6,5 +6,6 @@ <author>Bartek Przybylski</author> <require>2</require> <description>Dedicated pictures application</description> + <standalone/> <default_enable/> </info> diff --git a/apps/gallery/index.php b/apps/gallery/index.php index cf8bea14216..e47fb3db5d6 100755 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -38,7 +38,7 @@ if (!isset($_GET['view'])) { while ($row = $result->fetchRow()) $r[] = $row; - $tmpl = new OC_Template( 'gallery', 'index', 'user' ); + $tmpl = new OCP\Template( 'gallery', 'index', 'user' ); $tmpl->assign('r', $r); $tmpl->printPage(); } else { @@ -48,7 +48,7 @@ if (!isset($_GET['view'])) { while ($p = $result->fetchRow()) $photos[] = $p['file_path']; - $tmpl = new OC_Template( 'gallery', 'view_album', 'user' ); + $tmpl = new OCP\Template( 'gallery', 'view_album', 'user' ); $tmpl->assign('photos', $photos); $tmpl->assign('albumName', $_GET['view']); $tmpl->printPage(); diff --git a/apps/media/appinfo/info.xml b/apps/media/appinfo/info.xml index 01145d4a944..ea5b77c9c8f 100644 --- a/apps/media/appinfo/info.xml +++ b/apps/media/appinfo/info.xml @@ -6,5 +6,6 @@ <licence>AGPL</licence> <author>Robin Appelman</author> <require>2</require> + <standalone/> <default_enable/> </info> diff --git a/apps/media/index.php b/apps/media/index.php index e2911361ea2..906d7bacb6e 100755 --- a/apps/media/index.php +++ b/apps/media/index.php @@ -41,7 +41,7 @@ OCP\Util::addStyle('media','music'); OCP\App::setActiveNavigationEntry( 'media_index' ); -$tmpl = new OC_Template( 'media', 'music', 'user' ); +$tmpl = new OCP\Template( 'media', 'music', 'user' ); $tmpl->printPage(); ?> diff --git a/apps/media/settings.php b/apps/media/settings.php index 133440a9af6..227298fafec 100644..100755 --- a/apps/media/settings.php +++ b/apps/media/settings.php @@ -1,6 +1,6 @@ <?php -$tmpl = new OC_Template( 'media', 'settings'); +$tmpl = new OCP\Template( 'media', 'settings'); return $tmpl->fetchPage(); ?> diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php index 3959d989472..589d6b52475 100644..100755 --- a/apps/media/templates/music.php +++ b/apps/media/templates/music.php @@ -1,11 +1,11 @@ <div class='player-controls' id="controls"> <ul class="jp-controls"> - <li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play-big.svg'); ?>" /></a></li> - <li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause-big.svg'); ?>" /></a></li> - <li><a href="#" class="jp-previous action"><img class="svg" alt="<?php echo $l->t('Previous');?>" src="<?php echo image_path('core', 'actions/play-previous.svg'); ?>" /></a></li> - <li><a href="#" class="jp-next action"><img class="svg" alt="<?php echo $l->t('Next');?>" src="<?php echo image_path('core', 'actions/play-next.svg'); ?>" /></a></li> - <li><a href="#" class="jp-mute action"><img class="svg" alt="<?php echo $l->t('Mute');?>" src="<?php echo image_path('core', 'actions/sound.svg'); ?>" /></a></li> - <li><a href="#" class="jp-unmute action"><img class="svg" alt="<?php echo $l->t('Unmute');?>" src="<?php echo image_path('core', 'actions/sound-off.svg'); ?>" /></a></li> + <li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo OCP\image_path('core', 'actions/play-big.svg'); ?>" /></a></li> + <li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo OCP\image_path('core', 'actions/pause-big.svg'); ?>" /></a></li> + <li><a href="#" class="jp-previous action"><img class="svg" alt="<?php echo $l->t('Previous');?>" src="<?php echo OCP\image_path('core', 'actions/play-previous.svg'); ?>" /></a></li> + <li><a href="#" class="jp-next action"><img class="svg" alt="<?php echo $l->t('Next');?>" src="<?php echo OCP\image_path('core', 'actions/play-next.svg'); ?>" /></a></li> + <li><a href="#" class="jp-mute action"><img class="svg" alt="<?php echo $l->t('Mute');?>" src="<?php echo OCP\image_path('core', 'actions/sound.svg'); ?>" /></a></li> + <li><a href="#" class="jp-unmute action"><img class="svg" alt="<?php echo $l->t('Unmute');?>" src="<?php echo OCP\image_path('core', 'actions/sound-off.svg'); ?>" /></a></li> </ul> <div class="jp-progress"> <div class="jp-seek-bar"> diff --git a/apps/media/templates/player.php b/apps/media/templates/player.php index 146c743250e..4d478ec5f50 100644..100755 --- a/apps/media/templates/player.php +++ b/apps/media/templates/player.php @@ -1,7 +1,7 @@ <?php if(!isset($_)){//allow the template to be loaded standalone require_once '../../../lib/base.php'; - $tmpl = new OC_Template( 'media', 'player'); + $tmpl = new OCP\Template( 'media', 'player'); $tmpl->printPage(); exit; } @@ -10,8 +10,8 @@ if(!isset($_)){//allow the template to be loaded standalone <div class='player-controls' id="playercontrols"> <div class="player" id="jp-player"></div> <ul class="jp-controls"> - <li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play.svg'); ?>" /></a></li> - <li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause.svg'); ?>" /></a></li> - <li><a href="#" class="jp-next action"><img class="svg" alt="<?php echo $l->t('Next');?>" src="<?php echo image_path('core', 'actions/play-next.svg'); ?>" /></a></li> + <li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo OCP\image_path('core', 'actions/play.svg'); ?>" /></a></li> + <li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo OCP\image_path('core', 'actions/pause.svg'); ?>" /></a></li> + <li><a href="#" class="jp-next action"><img class="svg" alt="<?php echo $l->t('Next');?>" src="<?php echo OCP\image_path('core', 'actions/play-next.svg'); ?>" /></a></li> </ul> </div>
\ No newline at end of file diff --git a/apps/remoteStorage/settings.php b/apps/remoteStorage/settings.php index fa85f77a535..9c48549fe6d 100644..100755 --- a/apps/remoteStorage/settings.php +++ b/apps/remoteStorage/settings.php @@ -1,7 +1,7 @@ <?php require_once('lib_remoteStorage.php'); -$tmpl = new OC_Template( 'remoteStorage', 'settings'); +$tmpl = new OCP\Template( 'remoteStorage', 'settings'); return $tmpl->fetchPage(); ?> diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php index 20797f31aba..d86232e2da5 100644..100755 --- a/apps/tasks/ajax/addtaskform.php +++ b/apps/tasks/ajax/addtaskform.php @@ -8,7 +8,7 @@ $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true); $category_options = OC_Calendar_App::getCategoryOptions(); $percent_options = range(0, 100, 10); $priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OC_Template('tasks','part.addtaskform'); +$tmpl = new OCP\Template('tasks','part.addtaskform'); $tmpl->assign('calendars',$calendars); $tmpl->assign('category_options', $category_options); $tmpl->assign('percent_options', $percent_options); diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php index 78d1f193938..edcc8a7cdcd 100644..100755 --- a/apps/tasks/ajax/edittask.php +++ b/apps/tasks/ajax/edittask.php @@ -19,7 +19,7 @@ OC_Task_App::updateVCalendarFromRequest($_POST, $vcalendar); OC_Calendar_Object::edit($id, $vcalendar->serialize()); $priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OC_Template('tasks','part.details'); +$tmpl = new OCP\Template('tasks','part.details'); $tmpl->assign('priority_options', $priority_options); $tmpl->assign('details', $vcalendar->VTODO); $tmpl->assign('id', $id); diff --git a/apps/tasks/ajax/edittaskform.php b/apps/tasks/ajax/edittaskform.php index a439a0c0317..e5a0a7297c5 100644..100755 --- a/apps/tasks/ajax/edittaskform.php +++ b/apps/tasks/ajax/edittaskform.php @@ -12,7 +12,7 @@ $category_options = OC_Calendar_App::getCategoryOptions(); $percent_options = range(0, 100, 10); $priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OC_Template('tasks','part.edittaskform'); +$tmpl = new OCP\Template('tasks','part.edittaskform'); $tmpl->assign('category_options', $category_options); $tmpl->assign('percent_options', $percent_options); $tmpl->assign('priority_options', $priority_options); diff --git a/apps/tasks/ajax/getdetails.php b/apps/tasks/ajax/getdetails.php index 34ddaa7791a..4ce469e0c9c 100644..100755 --- a/apps/tasks/ajax/getdetails.php +++ b/apps/tasks/ajax/getdetails.php @@ -15,7 +15,7 @@ if (!$details){ } $priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OC_Template('tasks','part.details'); +$tmpl = new OCP\Template('tasks','part.details'); $tmpl->assign('priority_options', $priority_options); $tmpl->assign('details',$details->VTODO); $tmpl->assign('id',$id); diff --git a/apps/tasks/index.php b/apps/tasks/index.php index 8ed5f410434..5e17ca454ec 100644..100755 --- a/apps/tasks/index.php +++ b/apps/tasks/index.php @@ -28,7 +28,7 @@ OCP\App::setActiveNavigationEntry('tasks_index'); $categories = OC_Calendar_App::getCategoryOptions(); $l10n = new OC_L10N('tasks'); $priority_options = OC_Task_App::getPriorityOptions(); -$output = new OC_Template('tasks', 'tasks', 'user'); +$output = new OCP\Template('tasks', 'tasks', 'user'); $output->assign('priority_options', $priority_options); $output->assign('categories', $categories); $output -> printPage(); diff --git a/apps/tasks/templates/part.taskform.php b/apps/tasks/templates/part.taskform.php index da984d830bd..c00560903b0 100644..100755 --- a/apps/tasks/templates/part.taskform.php +++ b/apps/tasks/templates/part.taskform.php @@ -6,7 +6,7 @@ <br> <label for="categories"><?php echo $l->t('Categories'); ?></label> <input id="categories" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? htmlspecialchars($_['categories']) : '' ?>"> - <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a> + <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo OCP\image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a> <br> <label for="due"><?php echo $l->t('Due'); ?></label> <input type="text" id="due" name="due" placeholder="<?php echo $l->t('Due date') ?>" value="<?php echo isset($_['details']->DUE) ? $l->l('datetime', $_['details']->DUE[0]->getDateTime()) : '' ?>"> diff --git a/apps/tasks/templates/tasks.php b/apps/tasks/templates/tasks.php index 98698400797..ab6138b613f 100644..100755 --- a/apps/tasks/templates/tasks.php +++ b/apps/tasks/templates/tasks.php @@ -17,13 +17,13 @@ </div> <p id="task_actions_template" class="task_actions"> <!-- span class="task_star"> - <img title="<?php echo $l->t('Important') ?>" src="<?php echo image_path('core', 'actions/add.svg') ?>" class="svg"><?php echo $l->t('Important') ?> + <img title="<?php echo $l->t('Important') ?>" src="<?php echo OCP\image_path('core', 'actions/add.svg') ?>" class="svg"><?php echo $l->t('Important') ?> </span --> <span class="task_more"> - <img title="<?php echo $l->t('More') ?>" src="<?php echo image_path('core', 'actions/triangle-s.svg') ?>" class="svg"><?php echo $l->t('More') ?> + <img title="<?php echo $l->t('More') ?>" src="<?php echo OCP\image_path('core', 'actions/triangle-s.svg') ?>" class="svg"><?php echo $l->t('More') ?> </span> <span class="task_less"> - <img title="<?php echo $l->t('Less') ?>" src="<?php echo image_path('core', 'actions/triangle-n.svg') ?>" class="svg"><?php echo $l->t('Less') ?> + <img title="<?php echo $l->t('Less') ?>" src="<?php echo OCP\image_path('core', 'actions/triangle-n.svg') ?>" class="svg"><?php echo $l->t('Less') ?> </span> </p> <script type='text/javascript'> diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 7512aa3c942..71c14aad80d 100755 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -41,7 +41,7 @@ if ($_POST) { } // fill template -$tmpl = new OC_Template( 'user_ldap', 'settings'); +$tmpl = new OCP\Template( 'user_ldap', 'settings'); foreach($params as $param){ $value = OCP\Config::getAppValue('user_ldap', $param,''); $tmpl->assign($param, $value); diff --git a/apps/user_migrate/admin.php b/apps/user_migrate/admin.php index 93f9d59aa4d..df8bff01c8d 100755 --- a/apps/user_migrate/admin.php +++ b/apps/user_migrate/admin.php @@ -38,14 +38,14 @@ if (isset($_POST['user_import'])) { if( !move_uploaded_file( $from, $to ) ){ $error = array('error'=>'Failed to move the uploaded file','hint'=>'Try checking the permissions of the '.get_temp_dir().' dir.'); OCP\Util::writeLog( 'user_migrate', "Failed to copy the uploaded file", OCP\Util::ERROR ); - $tmpl = new OC_Template('user_migrate', 'admin'); + $tmpl = new OCP\Template('user_migrate', 'admin'); $tmpl->assign('error',$error); return $tmpl->fetchPage(); } $response = json_decode( OC_Migrate::import( $to, 'user' ) ); if( !$response->success ){ $error = array('error'=>'There was an error while importing the user!','hint'=>'Please check the logs for a more detailed explaination'); - $tmpl = new OC_Template('user_migrate', 'admin'); + $tmpl = new OCP\Template('user_migrate', 'admin'); $tmpl->assign('error',$error); return $tmpl->fetchPage(); } else { @@ -64,24 +64,24 @@ if (isset($_POST['user_import'])) { if( isset( $notsupported ) || isset( $failed ) ){ if( count( $failed ) > 0 ){ $error = array('error'=>'Some app data failed to import','hint'=>'App data for: '.implode(', ', $failed).' failed to import.'); - $tmpl = new OC_Template('user_migrate', 'admin'); + $tmpl = new OCP\Template('user_migrate', 'admin'); $tmpl->assign('error',$error); return $tmpl->fetchPage(); } else if( count( $notsupported ) > 0 ){ $error = array('error'=>'Some app data could not be imported, as the apps are not installed on this instance','hint'=>'App data for: '.implode(', ', $notsupported).' failed to import as they were not found. Please install the apps and try again'); - $tmpl = new OC_Template('user_migrate', 'admin'); + $tmpl = new OCP\Template('user_migrate', 'admin'); $tmpl->assign('error',$error); return $tmpl->fetchPage(); } } else { // Went swimmingly! - $tmpl = new OC_Template('user_migrate', 'admin'); + $tmpl = new OCP\Template('user_migrate', 'admin'); return $tmpl->fetchPage(); } } } else { // fill template - $tmpl = new OC_Template('user_migrate', 'admin'); + $tmpl = new OCP\Template('user_migrate', 'admin'); return $tmpl->fetchPage(); } diff --git a/apps/user_migrate/settings.php b/apps/user_migrate/settings.php index 2994d10a1eb..8edd0353388 100755 --- a/apps/user_migrate/settings.php +++ b/apps/user_migrate/settings.php @@ -25,5 +25,5 @@ OCP\App::checkAppEnabled('user_migrate'); // fill template -$tmpl = new OC_Template('user_migrate', 'settings'); +$tmpl = new OCP\Template('user_migrate', 'settings'); return $tmpl->fetchPage();
\ No newline at end of file diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 21d1c0a4545..137daa485a9 100755 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -559,7 +559,7 @@ function logout_mode () { */ function no_mode () { global $USERNAME, $profile; - $tmpl = new OC_Template( 'user_openid', 'nomode', 'guest' ); + $tmpl = new OCP\Template( 'user_openid', 'nomode', 'guest' ); if(substr($profile['req_url'],-1,1)!=='/'){//the identity should always end with a / $profile['req_url'].='/'; } diff --git a/apps/user_openid/settings.php b/apps/user_openid/settings.php index cdffab0bc25..921fa371dde 100755 --- a/apps/user_openid/settings.php +++ b/apps/user_openid/settings.php @@ -1,6 +1,6 @@ <?php -$tmpl = new OC_Template( 'user_openid', 'settings'); +$tmpl = new OCP\Template( 'user_openid', 'settings'); $identity=OCP\Config::getUserValue(OCP\USER::getUser(),'user_openid','identity',''); $tmpl->assign('identity',$identity); diff --git a/apps/user_openid/templates/nomode.php b/apps/user_openid/templates/nomode.php index 3bab4c2edd1..8952b542f00 100644..100755 --- a/apps/user_openid/templates/nomode.php +++ b/apps/user_openid/templates/nomode.php @@ -5,7 +5,7 @@ global $profile; ?> <div id="login"> - <img src="<?php echo image_path("", "logo.png"); ?>" alt="ownCloud" /> + <img src="<?php echo OCP\image_path("", "logo.png"); ?>" alt="ownCloud" /> <ul> <li class='error'> <div id="setup_form"> diff --git a/apps/user_webfinger/webfinger.php b/apps/user_webfinger/webfinger.php index da35cf29d0e..bb7bb68f776 100755 --- a/apps/user_webfinger/webfinger.php +++ b/apps/user_webfinger/webfinger.php @@ -25,15 +25,17 @@ $SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT)); $WEBROOT=substr($SUBURI,0,-34); */ +require_once('../../lib/base.php'); -$request = urldecode($_GET['q']); +$userName = ''; +$hostName = ''; +$request = strip_tags(urldecode($_GET['q'])); if($_GET['q']) { $reqParts = explode('@', $request); - $userName = $reqParts[0]; - $hostName = $reqParts[1]; -} else { - $userName = ''; - $hostName = ''; + if(count($reqParts)==2) { + $userName = $reqParts[0]; + $hostName = $reqParts[1]; + } } if(substr($userName, 0, 5) == 'acct:') { $userName = substr($userName, 5); diff --git a/files/webdav.php b/files/webdav.php index 3ed687041ca..7624ccbbc72 100644 --- a/files/webdav.php +++ b/files/webdav.php @@ -25,12 +25,9 @@ // Do not load FS ... $RUNTIME_NOSETUPFS = true; -require_once('../lib/base.php'); - // only need filesystem apps $RUNTIME_APPTYPES=array('filesystem','authentication'); - - +require_once('../lib/base.php'); // Backends $authBackend = new OC_Connector_Sabre_Auth(); diff --git a/index.php b/index.php index b9872a906d7..91f0cfb5e48 100644 --- a/index.php +++ b/index.php @@ -115,6 +115,6 @@ elseif(OC_User::isLoggedIn()) { if(is_null(OC::$REQUESTEDFILE)){ $sectoken=rand(1000000,9999999); $_SESSION['sectoken']=$sectoken; - OC_Template::printGuestPage('', 'login', array('error' => $error, 'sectoken' => $sectoken, 'redirect' => isset($_REQUEST['redirect_url'])?$_REQUEST['redirect_url']:'' )); + OC_Template::printGuestPage('', 'login', array('error' => $error, 'sectoken' => $sectoken, 'redirect' => isset($_REQUEST['redirect_url'])?strip_tags($_REQUEST['redirect_url']):'' )); } } diff --git a/lib/app.php b/lib/app.php index c8d3826bca5..f274194b25c 100644 --- a/lib/app.php +++ b/lib/app.php @@ -49,7 +49,7 @@ class OC_App{ * if $types is set, only apps of those types will be loaded */ public static function loadApps($types=null){ - // Did we allready load everything? + // Did we already load everything? if( self::$init ){ return true; } diff --git a/lib/filecache.php b/lib/filecache.php index 091a7939e1a..8763865c8c3 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -655,7 +655,7 @@ class OC_FileCache{ }else{ $view=new OC_FilesystemView(($root=='/')?'':$root); } - $dh=$view->opendir($path); + $dh=$view->opendir($path.'/'); if($dh){//check for changed/new files while (($filename = readdir($dh)) !== false) { if($filename != '.' and $filename != '..'){ diff --git a/lib/helper.php b/lib/helper.php index 82d1017debd..2ddd5e7b778 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -341,8 +341,8 @@ class OC_Helper { if (!$isWrapped and $mimeType=='application/octet-stream' && OC_Helper::canExecute("file")) { // it looks like we have a 'file' command, // lets see it it does have mime support - $path=str_replace("'","\'",$path); - $fp = popen("file -i -b '$path' 2>/dev/null", "r"); + $path=escapeshellarg($path); + $fp = popen("file -i -b $path 2>/dev/null", "r"); $reply = fgets($fp); pclose($fp); diff --git a/lib/migrate.php b/lib/migrate.php index f46d860e806..99926171b77 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -457,7 +457,7 @@ class OC_Migrate{ ); // Add hash if user export if( self::$exporttype == 'user' ){ - $query = OC_DB::prepare( "SELECT password FROM *PREFIX*users WHERE uid LIKE ?" ); + $query = OC_DB::prepare( "SELECT password FROM *PREFIX*users WHERE uid = ?" ); $result = $query->execute( array( self::$uid ) ); $row = $result->fetchRow(); $hash = $row ? $row['password'] : false; diff --git a/lib/public/app.php b/lib/public/app.php index 80d0fd22b6b..618ea03ad0f 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -32,16 +32,6 @@ namespace OCP; class App { - - /** - * @brief get the user id of the user currently logged in. - * @return string uid or false - */ - public static function getUser(){ - return \OC_USER::getUser(); - } - - /** * @brief makes owncloud aware of this app * @param $data array with all information @@ -63,14 +53,6 @@ class App { } - /** - * register an admin form to be shown - */ - public static function registerAdmin($app,$page){ - return \OC_App::registerAdmin($app,$page); - } - - /** * @brief adds an entry to the navigation * @param $data array containing the data @@ -89,26 +71,7 @@ class App { * the navigation. Lower values come first. */ public static function addNavigationEntry( $data ){ - return \OC_App::addNavigationEntry($data); - } - - - /** - * @brief Read app metadata from the info.xml file - * @param string $appid id of the app or the path of the info.xml file - * @param boolean path (optional) - * @returns array - */ - public static function getAppInfo($appid,$path=false){ - return \OC_App::getAppInfo($appid,$path); - } - - - /** - * register a personal form to be shown - */ - public static function registerPersonal($app,$page){ - return \OC_App::registerPersonal($app,$page); + return \OC_App::addNavigationEntry( $data ); } @@ -121,12 +84,44 @@ class App { * property from all other entries. The templates can use this for * highlighting the current position of the user. */ - public static function setActiveNavigationEntry($id){ - return \OC_App::setActiveNavigationEntry($id); + public static function setActiveNavigationEntry( $id ){ + return \OC_App::setActiveNavigationEntry( $id ); } /** + * @brief Register a Configuration Screen that should appear in the personal settings section. + * @param $app string appid + * @param $page string page to be included + */ + public static function registerPersonal( $app, $page ){ + return \OC_App::registerPersonal( $app, $page ); + } + + + /** + * @brief Register a Configuration Screen that should appear in the Admin section. + * @param $app string appid + * @param $page string page to be included + */ + public static function registerAdmin( $app, $page ){ + return \OC_App::registerAdmin( $app, $page ); + } + + + /** + * @brief Read app metadata from the info.xml file + * @param string $app id of the app or the path of the info.xml file + * @param boolean path (optional) + * @returns array + */ + public static function getAppInfo( $app, $path=false ){ + return \OC_App::getAppInfo( $app, $path); + } + + + + /** * @brief checks whether or not an app is enabled * @param $app app * @returns true/false @@ -139,27 +134,32 @@ class App { /** - * Check if the app is enabled, redirects to home if not + * @brief Check if the app is enabled, redirects to home if not + * @param $app app + * @returns true/false */ - public static function checkAppEnabled($app){ + public static function checkAppEnabled( $app ){ return \OC_Util::checkAppEnabled( $app ); } /** - * get the last version of the app, either from appinfo/version or from appinfo/info.xml + * @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml + * @param $app app + * @returns true/false */ - public static function getAppVersion($appid){ - return \OC_App::getAppVersion( $appid ); + public static function getAppVersion( $app ){ + return \OC_App::getAppVersion( $app ); } /** * @param string appid + * @param $app app * @return OC_FilesystemView */ - public static function getStorage($appid){ - return \OC_App::getStorage( $appid ); + public static function getStorage( $app ){ + return \OC_App::getStorage( $app ); } diff --git a/lib/public/config.php b/lib/public/config.php index 5681f20e3b3..43d97d993b7 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -33,8 +33,6 @@ namespace OCP; class Config { - - /** * @brief Gets a value from config.php * @param $key key diff --git a/lib/public/db.php b/lib/public/db.php index b534756a5a0..7ba98e2851e 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -44,6 +44,7 @@ class DB { return(\OC_DB::prepare($query)); } + /** * @brief gets last value of autoincrement * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix @@ -59,9 +60,8 @@ class DB { } - /** - * Start a transaction + * @brief Start a transaction */ public static function beginTransaction(){ return(\OC_DB::beginTransaction()); @@ -69,7 +69,7 @@ class DB { /** - * Commit the database changes done during a transaction that is in progress + * @brief Commit the database changes done during a transaction that is in progress */ public static function commit(){ return(\OC_DB::commit()); @@ -77,7 +77,7 @@ class DB { /** - * check if a result is an error, works with MDB2 and PDOException + * @brief check if a result is an error, works with MDB2 and PDOException * @param mixed $result * @return bool */ diff --git a/lib/public/files.php b/lib/public/files.php index f2153f33b90..e11ab81e16f 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -38,7 +38,7 @@ class Files { * @param string $dir path to the folder * */ - static function rmdirr($dir) { + static function rmdirr( $dir ) { \OC_Helper::rmdirr( $dir ); } @@ -49,18 +49,19 @@ class Files { * @return string * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead */ - static function getMimeType($path){ + static function getMimeType( $path ){ return(\OC_Helper::getMimeType( $path )); } + /** * copy the contents of one stream to another * @param resource source * @param resource target * @return int the number of bytes copied */ - public static function streamCopy($source,$target){ - return(\OC_Helper::streamCopy($source,$target)); + public static function streamCopy( $source, $target ){ + return(\OC_Helper::streamCopy( $source, $target )); } @@ -71,10 +72,11 @@ class Files { * * temporary files are automatically cleaned up after the script is finished */ - public static function tmpFile($postfix=''){ - return(\OC_Helper::tmpFile($postfix)); + public static function tmpFile( $postfix='' ){ + return(\OC_Helper::tmpFile( $postfix )); } + /** * create a temporary folder with an unique filename * @return string @@ -85,6 +87,7 @@ class Files { return(\OC_Helper::tmpFolder()); } + /** * Adds a suffix to the name in case the file exists * @@ -92,23 +95,13 @@ class Files { * @param $filename * @return string */ - public static function buildNotExistingFileName($path, $filename){ - return(\OC_Helper::buildNotExistingFileName($path, $filename)); + public static function buildNotExistingFileName( $path, $filename ){ + return(\OC_Helper::buildNotExistingFileName( $path, $filename )); } - - - - - - - - - - } ?> diff --git a/lib/public/json.php b/lib/public/json.php index 36d3bed807f..7fc6a0b01d4 100644 --- a/lib/public/json.php +++ b/lib/public/json.php @@ -33,57 +33,62 @@ namespace OCP; class JSON { - /** - * Encode and print $data in JSON format + * @brief Encode and print $data in JSON format + * @param array $data The data to use + * @param string $setContentType the optional content type */ - public static function encodedPrint($data,$setContentType=true){ - return(\OC_JSON::encodedPrint($data,$setContentType)); + public static function encodedPrint( $data, $setContentType=true ){ + return(\OC_JSON::encodedPrint( $data, $setContentType )); } + /** - * Check if the user is logged in, send json error msg if not + * @brief Check if the user is logged in, send json error msg if not */ public static function checkLoggedIn(){ return(\OC_JSON::checkLoggedIn()); } - /** - * Send json success msg + * @brief Send json success msg + * @param array $data The data to use */ - public static function success($data = array()){ - return(\OC_JSON::success($data)); + public static function success( $data = array() ){ + return(\OC_JSON::success( $data )); } /** - * Send json error msg + * @brief Send json error msg + * @param array $data The data to use */ - public static function error($data = array()){ - return(\OC_JSON::error($data)); + public static function error( $data = array() ){ + return(\OC_JSON::error( $data )); } /** - * set Content-Type header to jsonrequest + * @brief set Content-Type header to jsonrequest + * @param array $type The contwnt type header */ - public static function setContentTypeHeader($type='application/json'){ - return(\OC_JSON::setContentTypeHeader($type)); + public static function setContentTypeHeader( $type='application/json' ){ + return(\OC_JSON::setContentTypeHeader( $type )); } /** - * Check if the app is enabled, send json error msg if not - */ - public static function checkAppEnabled($app){ - return(\OC_JSON::checkAppEnabled($app)); + * @brief Check if the App is enabled and send JSON error message instead + * @param string $app The app to check + */ + public static function checkAppEnabled( $app ){ + return(\OC_JSON::checkAppEnabled( $app )); } /** - * Check if the user is a admin, send json error msg if not + * @brief Check if the user is a admin, send json error msg if not */ public static function checkAdminUser(){ return(\OC_JSON::checkAdminUser()); diff --git a/lib/public/response.php b/lib/public/response.php index 2efa74ef840..5049b0c54cf 100644 --- a/lib/public/response.php +++ b/lib/public/response.php @@ -40,8 +40,8 @@ class Response { * 0 and <0 enable default browser caching * null cache indefinitly */ - static public function enableCaching($cache_time = null) { - return(\OC_Response::enableCaching($cache_time)); + static public function enableCaching( $cache_time = null ) { + return(\OC_Response::enableCaching( $cache_time )); } @@ -50,8 +50,8 @@ class Response { * 'not modified' response * @param $lastModified time when the reponse was last modified */ - static public function setLastModifiedHeader($lastModified) { - return(\OC_Response::setLastModifiedHeader($lastModified)); + static public function setLastModifiedHeader( $lastModified ) { + return(\OC_Response::setLastModifiedHeader( $lastModified )); } @@ -69,8 +69,8 @@ class Response { * 'not modified' response * @param $etag token to use for modification check */ - static public function setETagHeader($etag) { - return(\OC_Response::setETagHeader($etag)); + static public function setETagHeader( $etag ) { + return(\OC_Response::setETagHeader( $etag )); } @@ -78,8 +78,8 @@ class Response { * @brief Send file as response, checking and setting caching headers * @param $filepath of file to send */ - static public function sendFile($filepath) { - return(\OC_Response::sendFile($filepath)); + static public function sendFile( $filepath ) { + return(\OC_Response::sendFile( $filepath )); } /** @@ -88,16 +88,16 @@ class Response { * string for DateInterval from now * DateTime object when to expire response */ - static public function setExpiresHeader($expires) { - return(\OC_Response::setExpiresHeader($expires)); + static public function setExpiresHeader( $expires ) { + return(\OC_Response::setExpiresHeader( $expires )); } /** * @brief Send redirect response * @param $location to redirect to */ - static public function redirect($location) { - return(\OC_Response::redirect($location)); + static public function redirect( $location ) { + return(\OC_Response::redirect( $location )); } diff --git a/lib/public/template.php b/lib/public/template.php index eefd2a029fc..d8f70c77fb2 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -40,17 +40,61 @@ namespace OCP; * For further information have a look at OC_Helper::imagePath */ function image_path( $app, $image ){ - return(image_path( $app, $image )); + return(\image_path( $app, $image )); } +/** + * @brief make OC_Helper::mimetypeIcon available as a simple function + * @param $mimetype mimetype + * @returns link to the image + * + * For further information have a look at OC_Helper::mimetypeIcon + */ +function mimetype_icon( $mimetype ){ + return(\mimetype_icon( $mimetype )); +} + + +/** + * @brief make OC_Helper::humanFileSize available as a simple function + * @param $bytes size in bytes + * @returns size as string + * + * For further information have a look at OC_Helper::humanFileSize + */ +function human_file_size( $bytes ){ + return(\human_file_size( $bytes )); +} + -class Template extends OC_Template { +/** + * TODO + */ +function relative_modified_date($timestamp) { + return(\relative_modified_date($timestamp)); +} + + +/** + * TODO + */ +function simple_file_size($bytes) { + return(\simple_file_size($bytes)); +} +/** + * TODO + */ +function html_select_options($options, $selected, $params=array()) { + return(\html_select_options($options, $selected, $params=array())); +} +class Template extends \OC_Template { } + ?> diff --git a/lib/public/user.php b/lib/public/user.php index c9f01d4a597..53ff8d25fc5 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -63,15 +63,17 @@ class User { return \OC_USER::isLoggedIn(); } + /** * @brief check if a user exists * @param string $uid the username * @return boolean */ - public static function userExists($uid){ - return \OC_USER::userExists($uid); + public static function userExists( $uid ){ + return \OC_USER::userExists( $uid ); } + /** * @brief Loggs the user out including all the session data * @returns true @@ -82,6 +84,7 @@ class User { return \OC_USER::logout(); } + /** * @brief Check if the password is correct * @param $uid The username @@ -91,9 +94,10 @@ class User { * Check if the password is correct without logging in the user */ public static function checkPassword( $uid, $password ){ - return \OC_USER::checkPassword($uid, $password); + return \OC_USER::checkPassword( $uid, $password ); } + /** * Check if the user is a admin, redirects to home if not */ @@ -101,6 +105,7 @@ class User { \OC_Util::checkAdminUser(); } + /** * Check if the user is logged in, redirects to home if not. With * redirect URL parameter to the request URI. @@ -110,6 +115,7 @@ class User { } + } diff --git a/lib/public/util.php b/lib/public/util.php index f5b8e798bb4..6a8adff0f5a 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -32,6 +32,7 @@ namespace OCP; class Util { + // consts for Logging const DEBUG=0; const INFO=1; @@ -39,8 +40,9 @@ class Util { const ERROR=3; const FATAL=4; + /** - * get the current installed version of ownCloud + * @brief get the current installed version of ownCloud * @return array */ public static function getVersion(){ @@ -49,8 +51,7 @@ class Util { /** - * send an email - * + * @brief send an email * @param string $toaddress * @param string $toname * @param string $subject @@ -59,41 +60,40 @@ class Util { * @param string $fromname * @param bool $html */ - public static function sendMail($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='') { + public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='') { // call the internal mail class - \OC_MAIL::send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc=''); + \OC_MAIL::send( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc=''); } + /** - * write a message in the log - * + * @brief write a message in the log * @param string $app * @param string $message * @param int level */ - public static function writeLog($app, $message, $level) { + public static function writeLog( $app, $message, $level ) { // call the internal log class - \OC_LOG::write($app, $message, $level); + \OC_LOG::write( $app, $message, $level ); } /** - * add a css file - * + * @brief add a css file * @param url $url */ public static function addStyle( $application, $file = null ){ - \OC_Util::addStyle($application, $file); + \OC_Util::addStyle( $application, $file ); } + /** - * add a javascript file - * + * @brief add a javascript file * @param appid $application * @param filename $file */ public static function addScript( $application, $file = null ){ - \OC_Util::addScript($application, $file); + \OC_Util::addScript( $application, $file ); } /** @@ -103,17 +103,16 @@ class Util { * @param string $text the text content for the element */ public static function addHeader( $tag, $attributes, $text=''){ - \OC_Util::addHeader($tag, $attribute, $text); + \OC_Util::addHeader( $tag, $attribute, $text ); } /** - * formats a timestamp in the "right" way - * + * @brief formats a timestamp in the "right" way * @param int timestamp $timestamp * @param bool dateOnly option to ommit time from the result */ public static function formatDate( $timestamp,$dateOnly=false){ - return(\OC_Util::formatDate($timestamp,$dateOnly)); + return(\OC_Util::formatDate( $timestamp,$dateOnly )); } @@ -151,7 +150,7 @@ class Util { * reverse proxies */ public static function getServerHost() { - return(\OC_Helper::severHost()); + return(\OC_Helper::serverHost()); } /** diff --git a/lib/user.php b/lib/user.php index 8b887559df3..816caff8dd8 100644 --- a/lib/user.php +++ b/lib/user.php @@ -117,15 +117,15 @@ class OC_User { // Check the name for bad characters // Allowed are: "a-z", "A-Z", "0-9" and "_.@-" if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $uid )){ - return false; + throw new Exception('Only the following characters are allowed in a username: "a-z", "A-Z", "0-9", and "_.@-"'); } // No empty username if(trim($uid) == ''){ - return false; + throw new Exception('A valid username must be provided'); } // Check if user already exists if( self::userExists($uid) ){ - return false; + throw new Exception('The username is already being used'); } diff --git a/lib/user/database.php b/lib/user/database.php index c1bac1bb0b5..4738a8948cb 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -122,7 +122,7 @@ class OC_User_Database extends OC_User_Backend { * Check if the password is correct without logging in the user */ public function checkPassword( $uid, $password ){ - $query = OC_DB::prepare( "SELECT uid, password FROM *PREFIX*users WHERE uid LIKE ?" ); + $query = OC_DB::prepare( "SELECT uid, password FROM *PREFIX*users WHERE uid = ?" ); $result = $query->execute( array( $uid)); $row=$result->fetchRow(); @@ -172,7 +172,7 @@ class OC_User_Database extends OC_User_Backend { * @return boolean */ public function userExists($uid){ - $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE uid LIKE ?" ); + $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE uid = ?" ); $result = $query->execute( array( $uid )); return $result->numRows() > 0; diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index 1ed53efcf06..6714711bc87 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -23,7 +23,8 @@ if( in_array( $username, OC_User::getUsers())){ } // Return Success story -if( OC_User::createUser( $username, $password )){ +try { + OC_User::createUser($username, $password); foreach( $groups as $i ){ if(!OC_Group::groupExists($i)){ OC_Group::createGroup($i); @@ -31,9 +32,8 @@ if( OC_User::createUser( $username, $password )){ OC_Group::addToGroup( $username, $i ); } OC_JSON::success(array("data" => array( "username" => $username, "groups" => implode( ", ", OC_Group::getUserGroups( $username ))))); -} -else{ - OC_JSON::error(array("data" => array( "message" => "Unable to add user" ))); +} catch (Exception $exception) { + OC_JSON::error(array("data" => array( "message" => $exception->getMessage()))); } ?> diff --git a/settings/js/users.js b/settings/js/users.js index eed93d3b303..e6eee4ce4fa 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -158,10 +158,11 @@ $(document).ready(function(){ event.preventDefault(); var username=$('#newusername').val(); if($('#content table tbody tr').filterAttr('data-uid',username).length>0){ + OC.dialogs.alert('The username is already being used', 'Error creating user'); return; } if($.trim(username) == '') { - alert('Please provide a username!'); + OC.dialogs.alert('A valid username must be provided', 'Error creating user'); return false; } var password=$('#newuserpassword').val(); @@ -177,6 +178,7 @@ $(document).ready(function(){ function(result){ if(result.status!='success'){ tr.remove(); + OC.dialogs.alert(result.data.message, 'Error creating user'); } } ); diff --git a/webapps.php b/webapps.php new file mode 100644 index 00000000000..99553fa8ef0 --- /dev/null +++ b/webapps.php @@ -0,0 +1,56 @@ +<?php + +/** +* ownCloud status page. usefull if you want to check from the outside if an owncloud installation exists +* +* @author Frank Karlitschek +* @copyright 2010 Frank Karlitschek karlitschek@kde.org +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + +$RUNTIME_NOAPPS = TRUE; //no apps, yet + +require_once('lib/base.php'); + + +//valid user account +if(isset($_SERVER['PHP_AUTH_USER'])) $authuser=$_SERVER['PHP_AUTH_USER']; else $authuser=''; +if(isset($_SERVER['PHP_AUTH_PW'])) $authpw=$_SERVER['PHP_AUTH_PW']; else $authpw=''; + +if(!OC_User::login($authuser,$authpw)){ + header('WWW-Authenticate: Basic realm="your valid user account"'); + header('HTTP/1.0 401 Unauthorized'); + exit; +}else{ + + $apps=OC_App::getEnabledApps(); + $values=array(); + foreach($apps as $app) { + $info=OC_App::getAppInfo($app); + if(isset($info['standalone'])) { + $newvalue=array('name'=>$info['name'],'url'=>OC_Helper::linkToAbsolute($app,''),'icon'=>''); + $values[]=$newvalue; + } + + } + + echo(json_encode($values)); + exit; + + +} + +?> |