Ejemplo n.º 1
0
 protected function actionSetNewPassword($params)
 {
     $response = array();
     if (!\GO\Base\Util\Http::isPostRequest() || empty($params['email']) || empty($params['usertoken'])) {
         $response['success'] = false;
         $response['feedback'] = "Invalid request!";
         return $response;
     }
     $user = \GO\Base\Model\User::model()->findSingleByAttribute('email', $params['email']);
     if ($user) {
         if ($params['usertoken'] == $user->getSecurityToken()) {
             $user->password = $_REQUEST['password'];
             $user->passwordConfirm = $_REQUEST['confirm'];
             if ($user->save()) {
                 $response['success'] = true;
             } else {
                 $response['success'] = false;
                 $response['feedback'] = nl2br(implode("<br />", $user->getValidationErrors()) . "\n");
             }
         } else {
             $response['success'] = false;
             $response['feedback'] = "Usertoken did not match!";
         }
     } else {
         $response['success'] = false;
         $response['feedback'] = "No user found!";
     }
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * Create a new Cronjob model
  */
 protected function actionCreate()
 {
     $model = new \GO\Base\Cron\CronJob();
     if (\GO\Base\Util\Http::isPostRequest()) {
         $model->setAttributes($_POST);
         $model->save();
         echo $this->renderSubmit($model);
     } else {
         echo $this->renderForm($model, array(), array('select' => false));
     }
 }
Ejemplo n.º 3
0
 /**
  * Update a new menu item
  * 
  * @param int $id
  * @param int $site_id
  */
 public function actionUpdate($id, $site_id)
 {
     $remoteComboFields = array();
     $model = $this->_loadModel($site_id, $id);
     if (!empty($model->content_id)) {
         $remoteComboFields['content_id'] = $model->content->title;
     }
     if (\GO\Base\Util\Http::isPostRequest()) {
         $model->setAttributes($_POST);
         $model->save();
     }
     echo $this->renderForm($model, $remoteComboFields);
 }
Ejemplo n.º 4
0
    public function actionData($params)
    {
        $response = array('success' => true, 'data' => array());
        try {
            $customCssFolder = new Folder(GO::config()->file_storage_path . 'customcss');
            if (!$customCssFolder->exists()) {
                $customCssFolder->create(0755);
            }
            $cssFile = new File(GO::config()->file_storage_path . 'customcss/style.css');
            $jsFile = new File(GO::config()->file_storage_path . 'customcss/javascript.js');
            if (Http::isPostRequest()) {
                if (isset($_POST['css'])) {
                    $cssFile->putContents($_POST['css']);
                }
                if (isset($_POST['javascript'])) {
                    $jsFile->putContents($_POST['javascript']);
                }
            }
            if ($cssFile->exists()) {
                $response['data']['css'] = $cssFile->getContents();
            } else {
                $response['data']['css'] = '/*
* Put custom styles here that will be applied to Group-Office. You can use the select file button to upload your logo and insert the URL in to this stylesheet.
*/

/* this will override the logo at the top right */
#headerLeft{
background-image:url(/insert/url/here) !important;
}

/* this will override the logo at the login screen */
.go-app-logo {
background-image:url(/insert/url/here) !important;
}';
            }
            if ($jsFile->exists()) {
                $response['data']['javascript'] = $jsFile->getContents();
            }
        } catch (Exception $e) {
            $response['feedback'] = $e->getMessage();
            $response['success'] = false;
        }
        echo $this->renderJson($response);
    }
Ejemplo n.º 5
0
 public function __construct()
 {
     if (!empty($_REQUEST['startdate'])) {
         $this->startDate = \GO\Base\Util\Date::to_unixtime($_REQUEST['startdate']);
     }
     if (!empty($_REQUEST['enddate'])) {
         $this->endDate = \GO\Base\Util\Date::date_add(\GO\Base\Util\Date::to_unixtime($_REQUEST['enddate']), 1);
     }
     if ($this->supportsStatusFilter()) {
         if (\GO\Base\Util\Http::isPostRequest()) {
             $this->statuses = !empty($_POST['status_id']) ? $_POST['status_id'] : array();
             \GO::config()->save_setting(get_class($this), json_encode($this->statuses), \GO::user()->id);
         } else {
             $statuses = \GO::config()->get_setting(get_class($this), \GO::user()->id);
             if ($statuses) {
                 $this->statuses = json_decode($statuses);
             }
         }
     }
 }
Ejemplo n.º 6
0
 protected function actionProfile()
 {
     $user = \GO::user();
     $contact = $user->contact;
     //set additional required fields
     $contact->setValidationRule('address', 'required', true);
     $contact->setValidationRule('zip', 'required', true);
     $contact->setValidationRule('city', 'required', true);
     //		$user->setValidationRule('passwordConfirm', 'required', false);
     $user->setValidationRule('password', 'required', false);
     \GO::config()->password_validate = false;
     if ($contact->company) {
         $company = $contact->company;
     } else {
         $company = new \GO\Addressbook\Model\Company();
         $company->addressbook_id = $contact->addressbook_id;
     }
     if (\GO\Base\Util\Http::isPostRequest()) {
         if (!empty($_POST['currentPassword']) && !empty($_POST['User']['password'])) {
             if (!$user->checkPassword($_POST['currentPassword'])) {
                 GOS::site()->notifier->setMessage('error', "Huidig wachtwoord onjuist");
                 unset($_POST['User']['password']);
                 unset($_POST['User']['passwordConfirm']);
             }
         } else {
             unset($_POST['User']['password']);
             unset($_POST['User']['passwordConfirm']);
         }
         $user->setAttributes($_POST['User']);
         $contact->setAttributes($_POST['Contact']);
         $company->setAttributes($_POST['Company']);
         $company->checkVatNumber = true;
         if (!empty($_POST['Company']['postAddressIsEqual'])) {
             $company->setPostAddressFromVisitAddress();
         }
         if (!GOS::site()->notifier->hasMessage('error') && $user->validate() && $contact->validate() && $company->validate()) {
             \GO::setIgnoreAclPermissions();
             //allow guest to create user
             $user->save();
             $company->save();
             $contact->company_id = $company->id;
             $contact->save();
             GOS::site()->notifier->setMessage('success', GOS::t('formEditSuccess'));
         } else {
             GOS::site()->notifier->setMessage('error', "Please check the form for errors");
         }
     }
     $company->post_address_is_address = false;
     if ($company->address == $company->post_address && $company->address_no == $company->post_address_no && $company->city == $company->post_city) {
         $company->post_address_is_address = true;
     }
     //clear values for form
     $user->password = "";
     $user->passwordConfirm = "";
     echo $this->render('profile', array('user' => $user, 'contact' => $contact, 'company' => $company));
 }
Ejemplo n.º 7
0
 /**
  * Page to show the "Active" ticket
  */
 protected function actionShowTicket()
 {
     // Check if the needed getters are given otherwise throw a notFound exception
     if (!isset($_GET['ticket_number']) && !isset($_GET['ticket_verifier'])) {
         throw new \GO\Base\Exception\NotFound();
     }
     // Check if we can find a ticket with the given getters
     $ticket = \GO\Tickets\Model\Ticket::model()->findSingleByAttributes(array('ticket_number' => $_GET['ticket_number'], 'ticket_verifier' => $_GET['ticket_verifier']));
     // If there is no ticket found then throw a notFound exception
     if (!$ticket) {
         throw new \GO\Base\Exception\NotFound();
     }
     // Create a new message object
     $message = new \GO\Tickets\Model\Message();
     // Create an instance of the uploader
     $uploader = new \GO\Site\Widgets\Uploader('uploader', $_REQUEST, 'createticket');
     // Authorize the uploader to handle the uploaded files
     \GO\Base\Authorized\Actions::setAuthorized('plupload');
     // Check for the form post
     if (\GO\Base\Util\Http::isPostRequest()) {
         // Add the posted attributes to the message object
         $message->setAttributes($_POST['Message']);
         // If the ticket is closed by the user
         if (isset($_POST['CloseTicket'])) {
             $message->setStatus(\GO\Tickets\Model\Ticket::STATUS_CLOSED);
         }
         // Add a message to the ticket.
         if ($ticket->addMessage($message)) {
             // If saving is OK then redirect to the ticket page
             $this->redirect(array('tickets/site/showTicket', 'ticket_number' => $ticket->ticket_number, 'ticket_verifier' => $ticket->ticket_verifier));
         }
     }
     // Create the pager for the messages
     $findParams = \GO\Base\Db\FindParams::newInstance();
     $findParams->getCriteria()->addCondition('ticket_id', $ticket->id);
     $findParams->getCriteria()->addCondition('is_note', false);
     $findParams->select('t.*');
     $findParams->order('ctime', 'DESC');
     $pager = new \GO\Site\Widgets\Pager('p', $_GET, \GO\Tickets\Model\Message::model(), $findParams, \GO::user() ? \GO::user()->max_rows_list : \GO::config()->nav_page_size, 2);
     // Build the view and pass the required parameters
     $this->render("ticket", array('ticket' => $ticket, 'message' => $message, 'pager' => $pager, 'uploader' => $uploader));
 }
Ejemplo n.º 8
0
 protected function actionCreate($params)
 {
     $model = new \GO\Site\Model\Content();
     $model->setAttributes($params);
     $model->setDefaultTemplate();
     if (\GO\Base\Util\Http::isPostRequest()) {
         $model->save();
         echo $this->renderSubmit($model);
     } else {
         echo $this->renderForm($model, array(), array('baseslug' => $model->baseslug, 'parentslug' => $model->parentslug));
     }
 }
Ejemplo n.º 9
0
 protected function actionContact()
 {
     //GOS::site()->config->contact_addressbook_id;
     if (\GO\Base\Util\Http::isPostRequest()) {
         if (isset($_POST['Addressbook']['name'])) {
             $addressbookModel = \GO\Addressbook\Model\Addressbook::model()->findSingleByAttribute('name', $_POST['Addressbook']['name']);
         } else {
             $addressbookModel = \GO\Addressbook\Model\Addressbook::model()->findByPk($_POST['Addressbook']['id']);
         }
         if (!$addressbookModel) {
             throw new \Exception(sprintf(\GO::t('addressbookNotFound', 'defaultsite'), $_POST['Addressbook']['name']));
         }
         $contactModel = \GO\Addressbook\Model\Contact::model()->findSingleByAttributes(array('email' => $_POST['Contact']['email'], 'addressbook_id' => $addressbookModel->id));
         if (!$contactModel) {
             $contactModel = new \GO\Addressbook\Model\Contact();
             $contactModel->addressbook_id = $addressbookModel->id;
         }
         $contactModel->setValidationRule('first_name', 'required', true);
         $contactModel->setValidationRule('last_name', 'required', true);
         $contactModel->setValidationRule('email', 'required', true);
         $companyModel = \GO\Addressbook\Model\Company::model()->findSingleByAttributes(array('name' => $_POST['Company']['name'], 'addressbook_id' => $addressbookModel->id));
         if (!$companyModel) {
             $companyModel = new \GO\Addressbook\Model\Company();
             $companyModel->addressbook_id = $addressbookModel->id;
         }
         $companyModel->setValidationRule('name', 'required', true);
         $companyModel->setAttributes($_POST['Company']);
         if ($companyModel->validate()) {
             $companyModel->save();
             $contactModel->company_id = $companyModel->id;
         }
         $contactModel->setAttributes($_POST['Contact']);
         if ($contactModel->validate()) {
             $saveSuccess = $contactModel->save();
             if ($saveSuccess) {
                 // Add to mailings.
                 $addresslists = !empty($_POST['Addresslist']) ? $_POST['Addresslist'] : array();
                 foreach ($addresslists as $addresslistName => $checked) {
                     if (!empty($checked)) {
                         $addresslistModel = \GO\Addressbook\Model\Addresslist::model()->findSingleByAttribute('name', $addresslistName);
                         if ($addresslistModel) {
                             $addresslistContactModel = \GO\Addressbook\Model\AddresslistContact::model()->findSingleByAttributes(array('contact_id' => $contactModel->id, 'addresslist_id' => $addresslistModel->id));
                             if (!$addresslistContactModel) {
                                 $addresslistContactModel = new \GO\Addressbook\Model\AddresslistContact();
                                 $addresslistContactModel->contact_id = $contactModel->id;
                                 $addresslistContactModel->addresslist_id = $addresslistModel->id;
                                 $addresslistContactModel->save();
                             }
                         }
                     }
                 }
                 echo $this->render('contactform_done');
             } else {
                 echo $this->render('contactform', array('contact' => $contactModel, 'company' => $companyModel, 'addressbook' => $addressbookModel));
             }
         } else {
             $validationErrors = $contactModel->getValidationErrors();
             foreach ($validationErrors as $valError) {
                 echo $valError;
             }
             echo $this->render('contactform', array('contact' => $contactModel, 'company' => $companyModel, 'addressbook' => $addressbookModel));
         }
     } else {
         $addressbookModel = new \GO\Addressbook\Model\Addressbook();
         $contactModel = new \GO\Addressbook\Model\Contact();
         $companyModel = new \GO\Addressbook\Model\Company();
         echo $this->render('contactform', array('contact' => $contactModel, 'company' => $companyModel, 'addressbook' => $addressbookModel));
     }
 }