Esempio n. 1
0
 public function add_photo()
 {
     $app = JFactory::getApplication();
     $userid = $app->input->get('userid', 0, 'INT');
     $album_id = $app->input->get('album_id', 0, 'INT');
     // Load the album
     $album = FD::table('Album');
     $album->load($album_id);
     $photo_obj = new EasySocialApiUploadHelper();
     $addphoto = $photo_obj->addPhotoAlbum($userid, $album_id);
     $album->params = $addphoto;
     return $album;
 }
Esempio n. 2
0
 function CreateGroup()
 {
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $user = FD::user($log_user->id);
     $config = FD::config();
     //create group post structure
     $grp_data = array();
     $result = new stdClass();
     $valid = 1;
     $title = $app->input->get('title', null, 'STRING');
     $parmalink = $app->input->get('parmalink', null, 'STRING');
     $description = $app->input->get('description', null, 'STRING');
     $type = $app->input->get('type', 0, 'INT');
     $categoryId = $app->input->get('category_id', 0, 'INT');
     $avtar_pth = '';
     $avtar_scr = '';
     $avtar_typ = '';
     $phto_obj = null;
     if (!empty($_FILES['file']['name'])) {
         $upload_obj = new EasySocialApiUploadHelper();
         //ckecking upload cover
         //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
         $phto_obj = $upload_obj->ajax_avatar($_FILES['file']);
         $avtar_pth = $phto_obj['temp_path'];
         $avtar_scr = $phto_obj['temp_uri'];
         $avtar_typ = 'upload';
         $avatar_file_name = $_FILES['file']['name'];
     }
     $cover_data = null;
     if (!empty($_FILES['cover_file']['name'])) {
         $upload_obj = new EasySocialApiUploadHelper();
         //ckecking upload cover
         $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'], 'cover_file');
         //$phtomod	= FD::model( 'Photos' );
         //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
         //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
         //
     }
     //
     //check title
     if (empty($title) || $title == null) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Invalid group name";
     }
     //check parmalink
     if (empty($parmalink) || $parmalink == null) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Invalid parmalink";
     }
     //check description
     if (empty($description) || $description == null) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Empty description not allowed";
     }
     //check group type
     if (empty($type) || $type == 0) {
         $valid = 0;
         $result->status = 0;
         $result->message[] = "Please Add group type";
     }
     if (!$valid) {
         return $result;
     } else {
         // create steps
         $db = FD::db();
         $group = FD::table('Group');
         FD::import('admin:/includes/group/group');
         $group = new SocialGroup();
         // Load front end's language file
         FD::language()->loadSite();
         $category = FD::table('GroupCategory');
         $category->load($categoryId);
         // Get the steps
         $stepsModel = FD::model('Steps');
         $steps = $stepsModel->getSteps($categoryId, SOCIAL_TYPE_CLUSTERS);
         // Get the fields
         $lib = FD::fields();
         $fieldsModel = FD::model('Fields');
         /*$post = $this->input->post->getArray();
         		$args = array(&$post, &$group, &$errors);*/
         // query written due to commented function not working
         $query = "SELECT a.id,a.unique_key\tFROM `#__social_fields` AS `a` \n\t\t\t\t\t\tLEFT JOIN `#__social_apps` AS `b` ON `b`.`id` = `a`.`app_id`\n\t\t\t\t\t\tLEFT JOIN `#__social_fields_steps` AS `d` ON `a`.`step_id` = `d`.`id` \n\t\t\t\t\t\tWHERE `a`.`step_id` = '" . $steps[0]->id . "' ORDER BY `d`.`sequence` ASC,`a`.`ordering` ASC";
         $db->setQuery($query);
         $field_ids = $db->loadAssocList();
         /*foreach ($steps as $step) {
         
         					if ($group->id) {
         						$step->fields 	= $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $group->id, 'dataType' => SOCIAL_TYPE_GROUP));
         					}
         					else {
         						$step->fields 	= $fieldsModel->getCustomFields(array('step_id' => $step->id));
         					}
         
         					
         				}*/
         foreach ($field_ids as $field) {
             $grp_data['cid'][] = $field['id'];
             switch ($field['unique_key']) {
                 case 'HEADER':
                     break;
                 case 'TITLE':
                     $grp_data['es-fields-' . $field['id']] = $title;
                     break;
                 case 'PERMALINK':
                     $grp_data['es-fields-' . $field['id']] = $parmalink;
                     break;
                 case 'DESCRIPTION':
                     $grp_data['es-fields-' . $field['id']] = $description;
                     break;
                 case 'TYPE':
                     $grp_data['group_type'] = $type;
                     break;
                 case 'URL':
                     $grp_data['es-fields-' . $field['id']] = $app->input->get('website', 0, 'STRING');
                     break;
                 case 'PHOTOS':
                     $grp_data['photo_albums'] = $app->input->get('photo_album', 0, 'INT');
                     break;
                 case 'NEWS':
                     $grp_data['es-fields-' . $field['id']] = $app->input->get('announcements', 0, 'INT');
                     break;
                 case 'DISCUSSIONS':
                     $grp_data['es-fields-' . $field['id']] = $app->input->get('discussions', 0, 'INT');
                     break;
                 case 'AVATAR':
                     $grp_data['es-fields-' . $field['id']] = array('source' => $avtar_scr, 'path' => $avtar_pth, 'data' => '', 'type' => $avtar_typ, 'name' => $avatar_file_name);
                     break;
                 case 'COVER':
                     $grp_data['es-fields-' . $field['id']] = array('data' => $cover_data, 'position' => '{"x":0.5,"y":0.5}');
                     break;
             }
         }
         //for check group exceed limit
         if (!$user->getAccess()->allowed('groups.create') && !$user->isSiteAdmin()) {
             $valid = 0;
             $result->status = 0;
             $result->message[] = "You are not allow to create the group";
             return $result;
         }
         // Ensure that the user did not exceed their group creation limit
         if ($user->getAccess()->intervalExceeded('groups.limit', $user->id) && !$user->isSiteAdmin()) {
             $valid = 0;
             $result->status = 0;
             $result->message[] = "Group creation limit exceeds";
             return $result;
         }
         // Get current user's info
         $session = JFactory::getSession();
         // Get necessary info about the current registration process.
         $stepSession = FD::table('StepSession');
         $stepSession->load($session->getId());
         $stepSession->uid = $categoryId;
         // Load the group category
         $category = FD::table('GroupCategory');
         $category->load($stepSession->uid);
         $sequence = $category->getSequenceFromIndex($stepSession->step, SOCIAL_GROUPS_VIEW_REGISTRATION);
         // Load the current step.
         $step = FD::table('FieldStep');
         $step->load(array('uid' => $category->id, 'type' => SOCIAL_TYPE_CLUSTERS, 'sequence' => $sequence));
         // Merge the post values
         $registry = FD::get('Registry');
         $registry->load($stepSession->values);
         // Load up groups model
         $groupsModel = FD::model('Groups');
         // Get all published fields apps that are available in the current form to perform validations
         $fieldsModel = FD::model('Fields');
         $fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'visible' => SOCIAL_GROUPS_VIEW_REGISTRATION));
         // Load json library.
         $json = FD::json();
         // Retrieve all file objects if needed
         //$files 		= JRequest::get( 'FILES' );
         $token = FD::token();
         $disallow = array($token, 'option', 'cid', 'controller', 'task', 'option', 'currentStep');
         foreach ($grp_data as $key => $value) {
             if (!in_array($key, $disallow)) {
                 if (is_array($value)) {
                     $value = FD::json()->encode($value);
                 }
                 $registry->set($key, $value);
             }
         }
         // Convert the values into an array.
         $data = $registry->toArray();
         $args = array(&$data, &$stepSession);
         // Perform field validations here. Validation should only trigger apps that are loaded on the form
         // @trigger onRegisterValidate
         $fieldsLib = FD::fields();
         // Get the trigger handler
         $handler = $fieldsLib->getHandler();
         // Get error messages
         $errors = $fieldsLib->trigger('onRegisterValidate', SOCIAL_FIELDS_GROUP_GROUP, $fields, $args, array($handler, 'validate'));
         // The values needs to be stored in a JSON notation.
         $stepSession->values = $json->encode($data);
         $stepSession->created = FD::date()->toMySQL();
         $group = $groupsModel->createGroup($stepSession);
         if ($group->id) {
             $result->status = 1;
             $result->id = $group->id;
             $this->addTostream($user, $group);
         } else {
             $result->status = 0;
             $result->id = 0;
             $result->message = 'unable to create group';
         }
         return $result;
     }
 }
Esempio n. 3
0
 public function create_field_arr($fields, $post)
 {
     $fld_data = array();
     $app = JFactory::getApplication();
     require_once JPATH_SITE . '/plugins/api/easysocial/libraries/uploadHelper.php';
     //for upload photo
     if (!empty($_FILES['avatar']['name'])) {
         $upload_obj = new EasySocialApiUploadHelper();
         //ckecking upload cover
         //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
         $phto_obj = $upload_obj->ajax_avatar($_FILES['avatar']);
         $avtar_pth = $phto_obj['temp_path'];
         $avtar_scr = $phto_obj['temp_uri'];
         $avtar_typ = 'upload';
         $avatar_file_name = $_FILES['avatar']['name'];
     }
     //for upload cover
     /*$cover_data = null;
       
       if(!empty($_FILES['cover_file']['name']))
       {
               $upload_obj = new EasySocialApiUploadHelper();
               //ckecking upload cover
               $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'],'cover_file');
               //$phtomod        = FD::model( 'Photos' );
               //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
               //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
               //
       }*/
     foreach ($fields as $field) {
         //$fld_data[$field->id] = $field->unique_key;
         $fobj = new stdClass();
         $fullname = $post['TITLE'] . " " . $post['first_name'] . " " . $post['middle_name'] . " " . $post['last_name'];
         $address = $post['STREET_1'] . "," . $post['STREET_2'] . "," . $post['CITY'] . "," . $post['PIN_CODE'] . "," . $post['STATE'] . "," . $post['COUNTRY'];
         // Hari code for address comma remove
         if ($address == ',,,,,') {
             $address = '';
         }
         $fld_data['first_name'] = !empty($post['first_name']) ? $post['first_name'] : $app->input->get('name', '', 'STRING');
         $fld_data['middle_name'] = $post['middle_name'];
         $fld_data['last_name'] = $post['last_name'];
         $fobj->first = $post['TITLE'] . " " . $fld_data['first_name'];
         $fobj->middle = $post['middle_name'];
         $fobj->last = $post['last_name'];
         $fobj->name = $fullname;
         switch ($field->unique_key) {
             case 'HEADER':
                 break;
             case 'JOOMLA_FULLNAME':
                 $fld_data['es-fields-' . $field->id] = $fobj;
                 break;
             case 'JOOMLA_USERNAME':
                 $fld_data['es-fields-' . $field->id] = $app->input->get('username', '', 'STRING');
                 break;
             case 'JOOMLA_PASSWORD':
                 $fld_data['es-fields-' . $field->id] = $app->input->get('password', '', 'STRING');
                 break;
             case 'JOOMLA_EMAIL':
                 $fld_data['es-fields-' . $field->id] = $app->input->get('email', '', 'STRING');
                 break;
             case 'JOOMLA_TIMEZONE':
                 $fld_data['es-fields-' . $field->id] = isset($post['timezone']) ? $post['timezone'] : null;
                 break;
             case 'JOOMLA_USER_EDITOR':
                 $fld_data['es-fields-' . $field->id] = isset($post['editor']) ? $post['editor'] : null;
                 break;
             case 'PERMALINK':
                 $fld_data['es-fields-' . $field->id] = isset($post['permalink']) ? $post['permalink'] : null;
                 break;
             case 'BIRTHDAY':
                 $bod = array();
                 if (isset($post['BIRTHDAY'])) {
                     $config = JFactory::getConfig();
                     $bod['date'] = $post['BIRTHDAY'];
                     $bod['timezone'] = $config->get('offset');
                 }
                 $fld_data['es-fields-' . $field->id] = isset($post['BIRTHDAY']) ? $bod : array();
                 break;
             case 'GENDER':
                 $fld_data['es-fields-' . $field->id] = isset($post['GENDER']) ? $post['GENDER'] : '';
                 break;
             case 'ADDRESS':
                 $fld_data['es-fields-' . $field->id] = $address;
                 break;
             case 'TEXTBOX':
                 $fld_data['es-fields-' . $field->id] = $post['MOBILE'];
                 break;
             case 'URL':
                 $fld_data['es-fields-' . $field->id] = isset($post['WEBSITE']) ? $post['WEBSITE'] : '';
                 break;
             case 'AVATAR':
                 $fld_data['es-fields-' . $field->id] = array('source' => $avtar_scr, 'path' => $avtar_pth, 'data' => '', 'type' => $avtar_typ, 'name' => $avatar_file_name);
                 break;
                 /*
                 				case 'COVER':	$fld_data['es-fields-'.$field->id] = Array
                 										(
                 											'data' =>$cover_data,
                 											'position' =>'{"x":0.5,"y":0.5}' 
                 										);
                 								break;*/
         }
     }
     return $fld_data;
 }
Esempio n. 4
0
 public function create_album()
 {
     // Get the uid and type
     $app = JFactory::getApplication();
     $uid = $app->input->get('uid', 0, 'INT');
     $type = $app->input->get('type', 0, 'USER');
     $title = $app->input->get('title', 0, 'USER');
     // Load the album
     $album = FD::table('Album');
     $album->load();
     // Determine if this item is a new item
     $isNew = true;
     if ($album->id) {
         $isNew = false;
     }
     // Load the album's library
     $lib = FD::albums($uid, $type);
     // Check if the person is allowed to create albums
     if ($isNew && !$lib->canCreateAlbums()) {
         return false;
     }
     // Set the album uid and type
     $album->uid = $uid;
     $album->type = $type;
     $album->title = $title;
     // Determine if the user has already exceeded the album creation
     if ($isNew && $lib->exceededLimits()) {
         return false;
     }
     // Set the album creation alias
     $album->assigned_date = FD::date()->toMySQL();
     // Set custom date
     if (isset($post['date'])) {
         $album->assigned_date = $post['date'];
         unset($post['date']);
     }
     // Set the user creator
     $album->user_id = $uid;
     // Try to store the album
     $state = $album->store();
     // Throw error when there's an error saving album
     if (!$state) {
         return false;
     }
     $photo_obj = new EasySocialApiUploadHelper();
     $photodata = $photo_obj->albumPhotoUpload($uid, $type, $album->id);
     $album->params = $photodata;
     if (!$album->cover_id) {
         $album->cover_id = $photodata->id;
         // Store the album
         $album->store();
     }
     return $album;
 }
Esempio n. 5
0
 public function createData($field_ids, $post)
 {
     $ev_data = array();
     $avtar_pth = '';
     $avtar_scr = '';
     $avtar_typ = '';
     $phto_obj = null;
     $avatar_file_name = null;
     if (!empty($_FILES['file']['name'])) {
         $upload_obj = new EasySocialApiUploadHelper();
         //ckecking upload cover
         //$phto_obj = $upload_obj->uploadPhoto($log_user->id,'group');
         $phto_obj = $upload_obj->ajax_avatar($_FILES['file']);
         $avtar_pth = $phto_obj['temp_path'];
         $avtar_scr = $phto_obj['temp_uri'];
         $avtar_typ = 'upload';
         $avatar_file_name = $_FILES['file']['name'];
     }
     $cover_data = null;
     if (!empty($_FILES['cover_file']['name'])) {
         $upload_obj = new EasySocialApiUploadHelper();
         //ckecking upload cover
         $cover_data = $upload_obj->ajax_cover($_FILES['cover_file'], 'cover_file');
         //$phtomod	= FD::model( 'Photos' );
         //$cover_obj = $upload_obj->uploadCover($log_user->id,'group');
         //$cover_data = $phtomod->getMeta($cover_obj->id, SOCIAL_PHOTOS_META_PATH);
         //
     }
     foreach ($field_ids as $field) {
         $ev_data['cid'][] = $field->id;
         switch ($field->unique_key) {
             case 'HEADER':
                 break;
             case 'TITLE':
                 $ev_data['es-fields-' . $field->id] = $post['title'];
                 unset($post['title']);
                 break;
             case 'PERMALINK':
                 $ev_data['es-fields-' . $field->id] = $post['parmalink'];
                 unset($post['parmalink']);
                 break;
             case 'DESCRIPTION':
                 $ev_data['es-fields-' . $field->id] = $post['description'];
                 unset($post['description']);
                 break;
             case 'URL':
                 $ev_data['es-fields-' . $field->id] = $post['website'];
                 unset($post['url']);
                 break;
                 /*case 'TYPE':	$ev_data['es-fields-'.$field->id] = $post['event_type'];
                 						break;
                 		case 'STARTEND':$ev_data['group_type'] = $post['startdate'];
                 						break;*/
                 /*case 'ALLDAY':	$ev_data['es-fields-'.$field->id] = $post['allday'];
                 		break;*/
                 /*case 'CONFIGALLOWMAYBE':	$ev_data['es-fields-'.$field->id] = $post['allowmaybe'];
                 						break;
                 		case 'CONFIGNOTGOINGGUEST':	$ev_data['es-fields-'.$field->id] = $post['allownotgoingguest'];
                 						break;
                 		case 'GUESTLIMIT':	$ev_data['es-fields-'.$field->id] = $post['guestlimit'];
                 						break;
                 		case 'PHOTOS':	$ev_data['es-fields-'.$field->id] = $post['photo_albums'];
                 						break;*/
             /*case 'TYPE':	$ev_data['es-fields-'.$field->id] = $post['event_type'];
             						break;
             		case 'STARTEND':$ev_data['group_type'] = $post['startdate'];
             						break;*/
             /*case 'ALLDAY':	$ev_data['es-fields-'.$field->id] = $post['allday'];
             		break;*/
             /*case 'CONFIGALLOWMAYBE':	$ev_data['es-fields-'.$field->id] = $post['allowmaybe'];
             						break;
             		case 'CONFIGNOTGOINGGUEST':	$ev_data['es-fields-'.$field->id] = $post['allownotgoingguest'];
             						break;
             		case 'GUESTLIMIT':	$ev_data['es-fields-'.$field->id] = $post['guestlimit'];
             						break;
             		case 'PHOTOS':	$ev_data['es-fields-'.$field->id] = $post['photo_albums'];
             						break;*/
             case 'NEWS':
                 $ev_data['es-fields-' . $field->id] = $post['announcement'];
                 unset($post['announcement']);
                 break;
             case 'DISCUSSIONS':
                 $ev_data['es-fields-' . $field->id] = $post['discussions'];
                 unset($post['discussions']);
                 break;
             case 'ADDRESS':
                 $ev_data['es-fields-' . $field->id] = $post['location'];
                 unset($post['location']);
                 break;
             case 'RECURRING':
                 $ev_data['es-fields-' . $field->id] = $post['repeat'];
                 unset($post['repeat']);
                 break;
             case 'AVATAR':
                 $ev_data['es-fields-' . $field->id] = array('source' => $avtar_scr, 'path' => $avtar_pth, 'data' => '', 'type' => $avtar_typ, 'name' => $avatar_file_name);
                 break;
             case 'COVER':
                 $ev_data['es-fields-' . $field->id] = array('data' => $cover_data, 'position' => '{"x":0.5,"y":0.5}');
                 break;
         }
     }
     $ev_data = array_merge($ev_data, $post);
     return $ev_data;
 }