Exemplo n.º 1
0
 static function save_list($name, $description)
 {
     require_once JPATH_ADMINISTRATOR . '/' . 'components' . '/' . 'com_acymailing' . '/' . 'helpers' . '/' . 'helper.php';
     $db = JFactory::getDBO();
     $list = new JObject();
     $list->name = $name;
     $list->alias = JFilterOutput::stringURLSafe(trim($name));
     $list->description = $description;
     $list->published = 1;
     $list->visible = 1;
     $list->userid = JoomdleHelperSystem::get_admin_id();
     $list->color = '#ffcc66';
     $status = $db->insertObject(acymailing_table('list'), $list);
     $insert_id = $db->insertid();
     // Re-order
     $orderClass = acymailing_get('helper.order');
     $orderClass->pkey = 'listid';
     $orderClass->table = 'list';
     $orderClass->groupMap = 'type';
     $orderClass->groupVal = 'list';
     $orderClass->reOrder();
     return $insert_id;
 }
Exemplo n.º 2
0
 static function add_activity_course_jomsocial($id, $name, $desc, $cat_id, $cat_name)
 {
     require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
     CFactory::load('libraries', 'activities');
     $cat_slug = JFilterOutput::stringURLSafe($cat_name);
     $course_slug = JFilterOutput::stringURLSafe($name);
     $mainframe = JFactory::getApplication('site');
     $mainframe->initialise();
     /* Kludge para que no pete el call_method */
     if ($desc == ' ') {
         $desc = '';
     }
     $user_id = JoomdleHelperSystem::get_admin_id();
     $act = new stdClass();
     $message = JText::_('COM_JOOMDLE_NEW_COURSE_AVAILABLE') . '';
     $link = "index.php?option=com_joomdle&view=detail&cat_id={$cat_id}:{$cat_slug}&course_id={$id}:{$course_slug}";
     $message .= ' <a href="' . $link . '">' . $name . '</a> ';
     $cat_link = "index.php?option=com_joomdle&view=coursecategory&cat_id={$cat_id}:{$cat_slug}";
     $message .= JText::_('COM_JOOMDLE_IN_CATEGORY') . " ";
     $message .= ' <a href="' . $cat_link . '">' . $cat_name . '</a> ';
     $act->cmd = 'joomdle.create';
     $act->actor = $user_id;
     $act->access = 0;
     $act->target = 0;
     $act->title = JText::_($message);
     $act->content = $desc;
     $act->app = 'joomdle';
     $act->cid = 0;
     CActivityStream::add($act);
     return "OK";
 }
Exemplo n.º 3
0
 static function addJSGroup($name, $description, $course_id, $website)
 {
     if (file_exists(JPATH_ADMINISTRATOR . '/components/com_community/tables/cache.php')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_community/tables/cache.php';
     }
     require_once JPATH_SITE . '/components/com_community/libraries/core.php';
     require_once JPATH_SITE . '/components/com_community/models/groups.php';
     $mainframe = JFactory::getApplication();
     // Get my current data.
     $validated = true;
     $group = JTable::getInstance('Group', 'CTable');
     $model = CFactory::getModel('groups');
     // @rule: Test for emptyness
     if (empty($name)) {
         $validated = false;
     }
     // @rule: Test if group exists
     if ($model->groupExist($name)) {
         $validated = false;
     }
     // @rule: Test for emptyness
     if (empty($description)) {
         $validated = false;
     }
     $categoryId = JoomdleHelperGroups::get_main_category();
     if (empty($categoryId)) {
         $validated = false;
     }
     if ($validated) {
         // Assertions
         // Category Id must not be empty and will cause failure on this group if its empty.
         CError::assert($categoryId, '', '!empty', __FILE__, __LINE__);
         // @rule: Retrieve params and store it back as raw string
         $params = new CParameter('');
         $discussordering = JRequest::getVar('discussordering', DISCUSSION_ORDER_BYLASTACTIVITY, 'REQUEST');
         $params->set('discussordering', $discussordering);
         $photopermission = JRequest::getVar('photopermission', GROUP_PHOTO_PERMISSION_ADMINS, 'REQUEST');
         $params->set('photopermission', $photopermission);
         $videopermission = JRequest::getVar('videopermission', GROUP_PHOTO_PERMISSION_ADMINS, 'REQUEST');
         $params->set('videopermission', $videopermission);
         $grouprecentphotos = JRequest::getVar('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT, 'REQUEST');
         $params->set('grouprecentphotos', $grouprecentphotos);
         $grouprecentvideos = JRequest::getVar('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT, 'REQUEST');
         $params->set('grouprecentvideos', $grouprecentvideos);
         $newmembernotification = JRequest::getVar('newmembernotification', '1', 'REQUEST');
         $params->set('newmembernotification', $newmembernotification);
         $joinrequestnotification = JRequest::getVar('joinrequestnotification', '1', 'REQUEST');
         $params->set('joinrequestnotification', $joinrequestnotification);
         $params->set('course_id', $course_id);
         CFactory::load('helpers', 'owner');
         $group->name = $name;
         $group->description = $description;
         $group->categoryid = $categoryId;
         $group->website = $website;
         $group->ownerid = JoomdleHelperSystem::get_admin_id();
         $group->created = gmdate('Y-m-d H:i:s');
         $group->approvals = 1;
         $group->params = $params->toString();
         // Set the default thumbnail and avatar for the group just in case
         // the user decides to skip this
         //   $group->thumb           = 'components/com_community/assets/group_thumb.jpg';
         //   $group->avatar          = 'components/com_community/assets/group.jpg';
         $group->published = 1;
         // Store the group now.
         $group->store();
         // Since this is storing groups, we also need to store the creator / admin
         // into the groups members table
         $member = JTable::getInstance('GroupMembers', 'CTable');
         $member->groupid = $group->id;
         $member->memberid = $group->ownerid;
         // Creator should always be 1 as approved as they are the creator.
         $member->approved = 1;
         // @todo: Setup required permissions in the future
         $member->permissions = '1';
         $member->store();
         // Increment the member count
         $group->updateStats();
         $group->store();
     }
     return "OK";
 }