Example #1
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Base_Validate', 'Base/Validate/', 'validate');
     $this->addElement('text', 'email_box', array('label' => 'Your Email', 'class' => 'form', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     // Add an first name element
     $this->addElement('text', 'name', array('label' => 'Your Name', 'class' => 'form', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter your name')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     /**
      * @Created By : Mahipal Adhikari
      * @Created on : 26-Oct-2010
      * @Description : set array to allow only selected services for open inviter as per client requiremnt
      **/
     //'facebook'=>'Facebook',
     $serviceAllowed = array('gmail' => 'GMail', 'yahoo' => 'Yahoo!', 'hotmail' => 'Hotmail', 'bebo' => 'Bebo', 'aol' => 'AOL', 'hi5' => 'Hi5', 'friendster' => 'Friendster', 'orkut' => 'Orkut', 'myspace' => 'MySpace');
     $inviter = new Base_OpenInviter_OpenInviter();
     $oi_services = $inviter->getPlugins();
     $arrayMain = array();
     $providersArray = array();
     foreach ($oi_services as $type => $providers) {
         foreach ($providers as $provider => $details) {
             //check if service is allowed
             if (array_key_exists($provider, $serviceAllowed)) {
                 $providersArray[$provider] = $details['name'];
             }
         }
         $arrayMain[$inviter->pluginTypes[$type]] = $providersArray;
     }
     //$oi_services['social'];
     $this->addElement('select', 'provider_box', array('label' => 'Select Account', 'class' => 'form', 'style' => 'width:221px;', 'value' => 'gmail', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrayMain));
     // Add an password element
     $this->addElement('password', 'password_box', array('label' => 'Your Password', 'autocomplete' => "off", 'class' => 'form', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('button', 'load', array('required' => false, 'class' => 'load_contacts', 'ignore' => true, 'label' => 'LOAD CONTACTS', 'decorators' => $this->buttonDecorators));
     $this->addElement('textarea', 'contacts', array('label' => 'Your Contacts', 'cols' => '40', 'rows' => '1', 'class' => 'invite-email_textarea', 'TABINDEX' => '6', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter your contacts')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'message', array('label' => 'Message', 'cols' => '50', 'rows' => '10', 'class' => 'textarea', 'value' => 'Gap Daemon Message here', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the message')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('submit', 'sendInvitataion', array('required' => false, 'class' => 'invite_button', 'ignore' => true, 'label' => 'SEND INVITE TO CONTACTS', 'decorators' => $this->buttonDecorators));
     $this->addElement('submit', 'inviteEmail', array('required' => false, 'class' => 'invite_button', 'ignore' => true, 'label' => 'INVITE', 'decorators' => $this->buttonDecorators));
     //add badword validations to each form fields
     $this->getElement('name')->addValidator('Badwords', true);
     $this->getElement('message')->addValidator('Badwords', true);
 }
Example #2
0
 public function loadContactsAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $email = $this->_getParam('email');
     $password = $this->_getParam('password');
     $provider = $this->_getParam('provider');
     $ers = array();
     if (empty($email)) {
         $ers['email'] = "Email missing !";
     }
     if (empty($password)) {
         $ers['password'] = "******";
     }
     if (empty($provider)) {
         $ers['provider'] = "Provider missing !";
     }
     if (count($ers) == 0) {
         // include_once(LIBRARY_PATH."/Base/OpenInviter/Base_OpenInviter_OpenInviter.php");
         $inviter = new Base_OpenInviter_OpenInviter();
         $oi_services = $inviter->getPlugins();
         $inviter->startPlugin($provider);
         $internal = $inviter->getInternalError();
         if ($internal) {
             $ers['inviter'] = $internal;
         } elseif (!$inviter->login($email, $password)) {
             $internal = $inviter->getInternalError();
             $ers['login'] = $internal ? $internal : "Login failed. Please check the email and password you have provided and try again later !";
         } elseif (false === ($contacts = $inviter->getMyContacts())) {
             $ers['contacts'] = "Unable to get contacts !";
         }
     }
     if (count($ers) == 0) {
         //print_r($contacts);
         $address = array();
         $address = array_keys($contacts);
         $data = "<input onchange='toggleAll(this)' style='width:20px' type='checkbox' value='contacts_all' id='contacts_all' name='contacts_all'><strong>Check All</strong><br/>";
         $i = 0;
         foreach ($contacts as $key => $val) {
             $data .= "<input style='width:20px' type='checkbox' value='{$key}' id='contacts_{$i}' name='contacts_{$i}'>{$val}<br/>";
             $i++;
         }
         //$data=implode(", ",$address);
         $result = array('error' => 0, 'data' => $data, 'total_contacts' => count($contacts), 'oi_session_id' => $inviter->plugin->getSessionID());
     } else {
         $ers = implode(", ", $ers);
         $result = array('error' => 1, 'data' => $ers);
     }
     echo Zend_Json::encode($result);
 }